loadFont
Function loadFont
loadFont(pdf: PDFDocument, source: AssetSource, options?: LoadFontOptions): Promise<PDFFont>Load a TTF/OTF font into the PDF. Accepts any of:
Uint8Array/ArrayBuffer— raw bytes.stringstarting withhttp://orhttps://— fetched at runtime.stringstarting withdata:— parsed as a data URL.stringmatching the base64 alphabet — decoded directly. This is the shape generated bynpx boxpdf font addand re-exported fromboxpdf/inter.
Registers @pdf-lib/fontkit on the document automatically (lazy-loaded
the first time loadFont is called).
Parameters
-
pdf: PDFDocument -
source: AssetSource -
options?: LoadFontOptions
Returns Promise<PDFFont>