UNPKG

pdfmkr

Version:

Generate PDF documents from JavaScript objects

48 lines (47 loc) 1.55 kB
import type { DocumentDefinition } from './document.ts'; import type { FontStyle, FontWeight } from './text.ts'; export type FontConfig = { family?: string; style?: FontStyle; weight?: FontWeight; }; /** * Generates PDF documents. */ export declare class PdfMaker { #private; constructor(); /** * Registers a font to be used in generated PDFs. * * @param data The font data. Must be in OpenType (OTF) or TrueType * (TTF) format. * @param config Additional configuration of the font, only needed if * the meta data cannot be extracted from the font. */ registerFont(data: Uint8Array, config?: FontConfig): void; /** * Sets the root directory to read resources from. This allows using * `file:/` URLs with relative paths in the document definition. * * @param root The root directory to read resources from. */ setResourceRoot(root: string): void; /** * Generates a PDF from the given document definition. * * @param definition The definition of the document to generate. * @returns The generated PDF document. */ makePdf(definition: DocumentDefinition): Promise<Uint8Array>; } /** * Generates a PDF from the given document definition. * * @param definition The definition of the document to generate. * @returns The generated PDF document. * * @deprecated Create an instance of `PdfMaker` and call `makePdf` on * that instance. */ export declare function makePdf(definition: DocumentDefinition): Promise<Uint8Array>;