@nova-slides/pdf-to-img
Version:
📃📸 Converts PDFs to images in nodejs
38 lines (37 loc) • 1.42 kB
TypeScript
/// <reference types="node" />
/// <reference types="node" />
import "./polyfill";
import type { DocumentInitParameters } from "pdfjs-dist/types/src/display/api";
export type PdfMetadata = {
Title?: string;
Author?: string;
Producer?: string;
Creator?: string;
CreationDate?: string;
ModDate?: string;
};
export type Options = {
/** For cases where the PDF is encrypted with a password */
password?: string;
/** @deprecated scale is not recommended with maxWidth or maxHeight, as scaling is determined by these values instead */
scale?: number;
/** document init parameters which are passed to pdfjs.getDocument */
docInitParams?: Partial<DocumentInitParameters>;
/** Maximum width of the output image */
maxWidth?: number;
/** Maximum height of the output image */
maxHeight?: number;
/** If true, maintain aspect ratio when maxWidth or maxHeight are specified. Defaults to true. */
maintainAspectRatio?: boolean;
};
/**
* Converts a PDF to a series of images. This returns a `Symbol.asyncIterator`
*
* @param input Either (a) the path to a pdf file, or (b) a data url, or (c) a buffer, or (d) a ReadableStream.
*
*/
export declare function pdf(input: string | Buffer | NodeJS.ReadableStream, options?: Options): Promise<{
length: number;
metadata: PdfMetadata;
[Symbol.asyncIterator](): AsyncIterator<Buffer, void, void>;
}>;