pdf-layout.ts
1/**2 * pdf-layout.ts — A4 Codex page geometry shared between the generator and3 * the PDF importer.4 *5 * The generator (`pdf.ts`) draws Aztec codes at exact pt positions on the6 * page. The importer (`pdf-import.ts`) must crop the matching regions out7 * of the rendered canvas before handing them to ZXing — Aztec decoding8 * cannot tolerate a clipped finder pattern. Keeping the constants in one9 * place is what stops the two from drifting (the original drift produced10 * the "no Codex codes found" PDF-import regression).11 *12 * Units are PDF points (1pt = 1/72 inch). A4 = 595.28 × 841.89 pt.13 */1415import { CODES_PER_ROW } from "../../shared/codex-types";1617export const PAGE_WIDTH = 595.28;18export const PAGE_HEIGHT = 841.89;1920export const MARGIN = 28;2122export const HEADER_HEIGHT = 44;23/** Vertical gap between the header hairline and the top of row 0. */24export const HEADER_GAP = 16;2526export const CODE_SIZE = 80;2728/** Horizontal gap between adjacent codes in a row. */29export const COL_GAP =30 (PAGE_WIDTH - 2 * MARGIN - CODES_PER_ROW * CODE_SIZE) / (CODES_PER_ROW - 1);3132/** Space reserved for the per-code numeric label drawn under each Aztec. */33export const LABEL_HEIGHT = 14;3435/** Vertical gap between rows (the printed white space between label and the next code). */36export const ROW_GAP = 18;3738/** Top-of-code-N to top-of-code-N+1 distance — what the importer steps by between rows. */39export const ROW_STEP = CODE_SIZE + ROW_GAP + LABEL_HEIGHT;