interface PDFParams {
    base64?: string;
    fileName?: string;
    html?: string;
    options?: {
        displayHeaderFooter?: boolean;
        footerTemplate?: string;
        format?: string;
        headerTemplate?: string;
        height?: string | number;
        landscape?: boolean;
        margin?: {
            bottom?: string | number;
            left?: string | number;
            right?: string | number;
            top?: string | number;
        };
        pageRanges?: string;
        preferCSSPageSize?: boolean;
        printBackground?: boolean;
        scale?: number;
        width?: string | number;
    };
    url?: string;
}

Properties

base64?: string

HTML on base64 format

fileName?: string

File name of pdf Without filename, it will generate base64 response With filename it will generate pdf binary

html?: string

HTML as string

options?: {
    displayHeaderFooter?: boolean;
    footerTemplate?: string;
    format?: string;
    headerTemplate?: string;
    height?: string | number;
    landscape?: boolean;
    margin?: {
        bottom?: string | number;
        left?: string | number;
        right?: string | number;
        top?: string | number;
    };
    pageRanges?: string;
    preferCSSPageSize?: boolean;
    printBackground?: boolean;
    scale?: number;
    width?: string | number;
}

PDF Custom Options

Type declaration

  • Optional displayHeaderFooter?: boolean

    Display header and footer. Defaults to false.

  • Optional footerTemplate?: string

    HTML template for the print footer. Should use the same format as the headerTemplate.

  • Optional format?: string

    Paper format. If set, takes priority over width or height options. Defaults to 'Letter'.

  • Optional headerTemplate?: string

    HTML template for the print header. Should be valid HTML markup with following classes used to inject printing values into them:

    • 'date' formatted print date
    • 'title' document title
    • 'url' document location
    • 'pageNumber' current page number
    • 'totalPages' total pages in the document
  • Optional height?: string | number

    Paper height, accepts values labeled with units.

  • Optional landscape?: boolean

    Paper orientation. Defaults to false.

  • Optional margin?: {
        bottom?: string | number;
        left?: string | number;
        right?: string | number;
        top?: string | number;
    }

    Paper margins, defaults to none.

    • Optional bottom?: string | number

      Bottom margin, accepts values labeled with units. Defaults to 0.

    • Optional left?: string | number

      Left margin, accepts values labeled with units. Defaults to 0.

    • Optional right?: string | number

      Right margin, accepts values labeled with units. Defaults to 0.

    • Optional top?: string | number

      Top margin, accepts values labeled with units. Defaults to 0.

  • Optional pageRanges?: string

    Paper ranges to print, e.g., '1-5, 8, 11-13'. Defaults to the empty string, which means print all pages.

  • Optional preferCSSPageSize?: boolean

    Give any CSS @page size declared in the page priority over what is declared in width and height or format options. Defaults to false, which will scale the content to fit the paper size.

  • Optional printBackground?: boolean

    Print background graphics. Defaults to false.

  • Optional scale?: number

    Scale of the webpage rendering. Defaults to 1. Scale amount must be between 0.1 and 2.

  • Optional width?: string | number

    Paper width, accepts values labeled with units.

url?: string

Generate pdf from URL