/** * LayoutDocument → PDF translation layer. * * Consumes the fully-positioned `LayoutDocument` produced by * `@word/layout/layout-full` and emits PDF operators via * `PdfDocumentBuilder`. Coordinate translation is the only logic * here — every flow decision (line wrapping, page breaks, table cell * sizing, float positioning, footnote placement) has already been * resolved by the layout engine. * * The Word layout coordinate system uses points with origin at the * top-left of the **content area** of each page (not the page itself), * with Y increasing downwards. The PDF coordinate system uses points * with origin at the bottom-left of the page and Y increasing upwards. * `pdfY = pageHeight - (geometry.marginTop + layoutY) - lineHeight`, * with the per-element `lineHeight` baked into rect.height for non- * paragraph variants and per-line for paragraphs. */ import type { LayoutChart, LayoutDocument } from "../word/layout/layout-model.js"; import { PdfDocumentBuilder, type PdfPageBuilder } from "./builder/document-builder.js"; /** Options for rendering a LayoutDocument into a PdfDocumentBuilder. */ export interface RenderLayoutOptions { /** Document title (sets PDF metadata). */ readonly title?: string; /** Document author (sets PDF metadata). */ readonly author?: string; /** Document subject. */ readonly subject?: string; /** Document creator (defaults to "excelts"). */ readonly creator?: string; /** Default font family used when a paragraph run has no explicit font. */ readonly defaultFont?: string; /** Default font size in points. */ readonly defaultFontSize?: number; /** * Optional pluggable chart renderer. Receives the bounding rect * (already translated into PDF coordinates) and the layout chart * info; the implementation paints onto `page` directly. * * Return value semantics: * - `true` (or `void`) — the renderer handled this chart; no further * fallback drawing happens. * - `false` — the renderer declined this chart (e.g. it only knows * how to draw a specific chart family); the translator falls back * to its built-in path (inline `LayoutChart.svg` if present, * otherwise a placeholder box with the chart title). * * The boolean variant lets a chart-aware host plug in a renderer * that handles classic `` while still letting `chartEx` * variants fall through to the simple placeholder. */ readonly chartRenderer?: (chart: LayoutChart, page: PdfPageBuilder, rect: { x: number; y: number; width: number; height: number; }) => boolean | void; } /** * Render a `LayoutDocument` into a freshly-constructed * `PdfDocumentBuilder`. Call `.build()` on the returned builder to get * the final PDF bytes; alternatively use {@link layoutToPdfBytes}. */ export declare function renderLayoutDocumentToPdf(layout: LayoutDocument, options?: RenderLayoutOptions): PdfDocumentBuilder; /** Convenience: render and immediately serialise to PDF bytes. */ export declare function layoutToPdfBytes(layout: LayoutDocument, options?: RenderLayoutOptions): Promise;