open-nav
    Preparing search index...

    Interface PdfOptions

    interface PdfOptions {
        browserArgs?: string[];
        browserPath?: string;
        convert?: (html: string) => Promise<Buffer<ArrayBufferLike>>;
        documentType?: DocumentType;
        engine?: "native" | "browser";
        env?: Record<string, string | undefined>;
        font?: PdfFont;
        language?: DocumentLanguage;
        note?: string;
        provenanceNote?: boolean;
        sandbox?: boolean;
        searchPaths?: readonly string[];
        theme?: InvoiceTheme;
        timeoutMs?: number;
    }

    Hierarchy (View Summary)

    Index
    browserArgs?: string[]

    Extra arguments passed to the browser.

    browserPath?: string

    Browser executable. Auto-detected when omitted. browser engine only.

    convert?: (html: string) => Promise<Buffer<ArrayBufferLike>>

    Convert HTML to PDF yourself, instead of spawning a browser.

    import { chromium } from 'playwright';
    const convert = async (html: string) => {
    const browser = await chromium.launch();
    const page = await browser.newPage();
    await page.setContent(html, { waitUntil: 'load' });
    const pdf = await page.pdf({ printBackground: true });
    await browser.close();
    return pdf;
    };
    documentType?: DocumentType

    The kind of document to render. Defaults to invoice (the tax invoice). proforma, deliveryNote and receipt are printable business documents rendered from the same data but reported nowhere through Online Számla; they drop the money detail they should not show and carry a "not a tax invoice" note instead of the NAV-provenance note. See DocumentType.

    engine?: "native" | "browser"

    Which engine to use.

    native (the default) needs nothing installed. browser follows the HTML document exactly but requires Chrome, Chromium or Edge.

    env?: Record<string, string | undefined>

    Environment consulted when detecting a browser. Injectable for tests.

    font?: PdfFont

    Replace Roboto with your own font files.

    language?: DocumentLanguage

    Document language. Hungarian by default, as the law prescribes.

    note?: string

    Extra note printed under the totals, e.g. payment instructions.

    provenanceNote?: boolean

    State that the document was rendered from reported data.

    On by default. An invoice's legal original is whatever the issuer issued; this rendering is a faithful presentation of the reported data, and saying so avoids passing it off as something it is not. Can also be set through the theme.

    sandbox?: boolean

    Run the browser with its sandbox. On by default.

    The sandbox is what contains a malicious document, and invoice data is input. It is left on even though that means conversion fails when running as root — in a container or CI, pass sandbox: false deliberately. The error message says so, rather than quietly weakening the default for everybody.

    searchPaths?: readonly string[]

    Absolute locations probed when detecting a browser, in place of the usual install paths. Injectable for tests: those paths are the host's, so without this a test cannot describe a machine that has no browser.

    theme?: InvoiceTheme

    Branding and layout: logo, colours, fonts, page setup, footer.

    See InvoiceTheme. Anything omitted falls back to a restrained default that prints well in black and white.

    timeoutMs?: number

    Give up after this long. Defaults to 30 000 ms.