UNPKG

pdf-to-png-converter

Version:

Node.js utility to convert PDF file/buffer pages to PNG files/buffers. No build-time compilation required — pre-built native binaries included for all major platforms.

23 lines (22 loc) 1.48 kB
import type { PDFDocumentProxy } from 'pdfjs-dist'; import type { InMemoryPngPageOutput, PngPageOutput } from './interfaces/index.js'; import type { PageMode } from './pageMode.js'; /** The two `PageMode`s that involve an actual render (everything except `metadata`). */ export type RenderedPageMode = Exclude<PageMode, { kind: 'metadata'; }>; export declare function resolvePageName(pageNumber: number, defaultMask: string, outputFileMaskFunc: ((page: number) => string) | undefined): string; /** * Applies the output half of a page's lifecycle to an already-rendered page: pass-through for * in-memory mode, or sink write + content trimming for file mode. Split out from * `processAndSavePage` so worker-thread conversions — where rendering happens off-thread but * output must stay on the main thread (path-security guards live here) — reuse the exact same * output logic. */ export declare function finalizePageOutput(pageOutput: InMemoryPngPageOutput, mode: RenderedPageMode): Promise<PngPageOutput>; /** * Returns whether a rendered page must materialize its PNG Buffer. `file` mode always does (the * bytes are needed for the write); `content` mode only when the caller asked to keep it. */ export declare function shouldMaterializeContent(mode: RenderedPageMode): boolean; export declare function processAndSavePage(pdfDocument: PDFDocumentProxy, pageName: string, pageNumber: number, pageViewportScale: number, mode: PageMode): Promise<PngPageOutput>;