Constructors

Accessors

  • get document(): PDFDocumentProxy
  • Get the PDF document after having it loaded. Usefull to get (for example) the number of pages of the document.

    Returns PDFDocumentProxy

Methods

  • Convert the PDF to images according to the options provided.

    Parameters

    • options: PDFToIMGOptions

      Options respecting the PDFToIMGOptions interface. Duplicate page index will be removed. The whole document is taken into account if pages is undefined. Returns only the pages that have been converted.

    Returns Promise<ImagePageOutput[]>

  • Get the text content and the language of the document, page per page. Usefull if you want to render only some pages based on the text content (conversion can be CPU intensive).

    Parameters

    • Optionalpages: number[]

      The pages to get the content from. The whole document is taken into account if pages is undefined or empty.

    Returns Promise<Text[]>

  • Get total size of images in Mb on disk.

    Returns Promise<number>

  • Load the PDF with the options provided. Throws an error if the PDF load fails.

    Parameters

    • file: string | Buffer

      The local path of your file or a Buffer

    • Optionaloptions: PDFOptions

      Options respecting the PDFOptions interface

    Returns Promise<PDFToImage>

  • Listen to a conversion status change.

    Type Parameters

    Parameters

    • event: K
    • listener: (data: Events[K]) => void

      Callback fired at event emission.

    Returns EventEmitter<DefaultEventMap>

    const pdf = await new PDFToImage().load(filePath);

    pdf.on('progress', (data) => {
    console.log(`${data}`);
    });
  • Pause all conversions processes.

    Returns void

  • Remove the generated images. Do not remove the containing directory.

    Returns Promise<void>

  • Resume all conversions processes after beeing paused. Returns all the converted images.

    Returns Promise<ImagePageOutput[]>

  • Stop and remove all pending conversions processes.

    Returns void