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