pdf-to-png-converter-allow-yarn
Version:
Node.js utility to convert PDF file/buffer pages to PNG files/buffers with no native dependencies.
22 lines (21 loc) • 844 B
TypeScript
import { PdfToPngOptions, PngPageOutput } from './types';
/**
* Converts a PDF file to PNG images.
*
* @param pdfFile - The path to the PDF file or a buffer containing the PDF data.
* @param props - Optional properties to customize the conversion process.
* @returns A promise that resolves to an array of PNG page outputs.
*
* @throws Will throw an error if invalid pages are requested when `strictPagesToProcess` is true.
*
* @example
* ```typescript
* const pngPages = await pdfToPng('/path/to/pdf/file.pdf', {
* pagesToProcess: [1, 2, 3],
* outputFolder: '/path/to/output/folder',
* viewportScale: 2.0,
* outputFileMaskFunc: (pageNumber) => `custom_name_page_${pageNumber}.png`,
* });
* ```
*/
export declare function pdfToPng(pdfFile: string | ArrayBufferLike, props?: PdfToPngOptions): Promise<PngPageOutput[]>;