Skip to content

feat: printf as pdf in wiki

Daniel Schmidt requested to merge instantnoodl/wiki-print-pdf into master

Changes to print-internals

  • Expose puppeteers PDFOptions as optional options, this allows the insertion of footerTemplate/headerTemplate/margins and so on.
/**
 * Valid options to configure PDF generation via {@link Page.pdf}.
 * @public
 */
export declare interface PDFOptions {
    scale?: number;
    displayHeaderFooter?: boolean;
    headerTemplate?: string;
    footerTemplate?: string;
    printBackground?: boolean;
    landscape?: boolean;
    pageRanges?: string;
    format?: PaperFormat;
    width?: string | number;
    height?: string | number;
    preferCSSPageSize?: boolean;
    margin?: PDFMargin;
    path?: string;
    omitBackground?: boolean;
    tagged?: boolean;
    outline?: boolean;
    timeout?: number;
}

All the createPDF functions have options as last optional param now:

export const createPDFFromUrl = (url: string, timeoutMS: number = 5000, sessionID?: string, options?: PDFOptions)
export const createPDFFromContent = (html: string, timeoutMS: number = 5000, options?: PDFOptions)
export const createPDFBufferFromComponent = async ({
  component,
  queryParams = '',
  timeout,
  sessionID,
  options,
}: {
  component: string;
  queryParams?: string;
  timeout?: number;
  sessionID?: string;
  options?: PDFOptions;
})
export const createPDFFromComponent = async ({
  component,
  queryParams = '',
  timeout,
  fileName,
  sessionID,
  options,
}: {
  component: string;
  queryParams?: string;
  timeout?: number;
  fileName?: string;
  sessionID?: string;
  options?: PDFOptions;
})
Edited by Daniel Schmidt

Merge request reports

Loading