@brakebein/pdf2png
Version:
Convert pages of a PDF document to PNG images
44 lines (43 loc) • 1.25 kB
TypeScript
export interface PdfConvertOptions {
/**
* Resolution of the output image in dpi.
* @default 600
*/
resolution?: number;
/**
* Path to ghostscript bin directory.
* @default Included Windows version
*/
ghostscriptPath?: string;
}
export declare class PdfConvert {
private readonly options;
private readonly source;
private tmpFile;
/**
* Constructs a new Convert Object
* @param source Can be either the buffer of the data, a file path, or a web url to a file.
* @param options Configuration object
*/
constructor(source: Buffer | string, options?: PdfConvertOptions);
/**
* Convert a page to a png image.
* @param page Page number
* @return png image as buffer
*/
convertPageToImage(page: number): Promise<Buffer>;
/**
* Gets the page count of the pdf.
* @returns Number of pages in the pdf.
*/
getPageCount(): Promise<number>;
/**
* Writes the source file to a tmp location.
*/
private writePDFToTemp;
/**
* Removes the temp file created for the PDF conversion.
* This should be called manually in case you want to do multiple operations.
*/
dispose(): Promise<void>;
}