@quario/pdf
The paginated PDF render target. Typesets the pages itself and resolves the document bytes.
pdf(options?)
function pdf(options?: PdfOptions): Target<'pdf', Promise<Uint8Array>>Returns the target. It validates options at the factory call, and takes three:
page, meta and fonts. Any other key, or one of the wrong type, throws a
TypeError naming the path. The factory copies meta as it reads it, so
mutating that object afterwards changes nothing the target writes.
PdfOptions
| Field | Type | Meaning |
|---|---|---|
page |
PdfPage |
Page geometry. |
meta |
PdfMeta |
Optional /Info dictionary. |
fonts |
Record<string, PdfFontFamily> |
TrueType families to embed, selected from styles by family. |
PdfPage
interface PdfPage {
size?: 'A4' | 'letter' | [number, number]
margin?: number
}size defaults to 'A4', which is 595.28 by 841.89 points. An array is a
custom [width, height] in points. margin is points on all four sides,
defaulting to 54, and applies when the document doesn’t declare page.margin.
Declaring it in both places is a render error.
PdfMeta
interface PdfMeta {
title?: string
author?: string
subject?: string
}Strings only, never dates, so output stays deterministic.
PdfFontFamily
interface PdfFontFamily {
regular: Uint8Array | ArrayBuffer
bold?: Uint8Array | ArrayBuffer
italic?: Uint8Array | ArrayBuffer
boldItalic?: Uint8Array | ArrayBuffer
}A missing variant falls back to regular. Embedding requires the optional peer
fontkit. The base-14 families need nothing extra.