UNPKG

safeer-pdf-generator

Version:

Framework-agnostic PDF generation library with chunking, merging, S3 upload, and email delivery

68 lines 2.21 kB
import { Browser, Page } from 'puppeteer'; import { PuppeteerOptions, PdfOptions, LoggingAdapter } from '../types.js'; /** * PDF generation engine using Puppeteer */ export declare class PdfEngine { private browser; private readonly isExternalBrowser; private readonly logger; private readonly puppeteerOptions; private readonly pdfOptions; constructor(puppeteerOptions?: PuppeteerOptions, pdfOptions?: PdfOptions, logger?: LoggingAdapter); /** * Launch the browser if not already launched */ launchBrowser(): Promise<Browser>; /** * Wait for web fonts (@font-face / @import) to finish loading before printing. * setContent with waitUntil:'domcontentloaded' resolves before fonts are ready, * which causes two visible bugs: * - text renders in a fallback font (e.g. Tajawal/Arabic fails to apply) * - position:fixed page headers appear only on page 1 instead of every page * Capped at 5 s; if fonts.ready never resolves (or is unsupported) we proceed * to print rather than hang the render. */ private waitForFonts; /** * Generate PDF from HTML content */ generatePdf(html: string, headerTemplate?: string, footerTemplate?: string, customPdfOptions?: Partial<PdfOptions>): Promise<Buffer>; /** * Generate multiple PDF chunks concurrently */ generateChunks(htmlChunks: Array<{ html: string; header?: string; footer?: string; }>, maxConcurrency?: number, onChunkDone?: (chunkIndex: number, buffer: Buffer) => void): Promise<Buffer[]>; /** * Close the browser */ close(): Promise<void>; /** * Check if browser is running */ isRunning(): boolean; /** * Get browser process ID */ getPid(): number | undefined; /** * Get browser path with fallbacks */ private getBrowserPath; /** * Get browser version info */ getBrowserVersion(): Promise<string>; /** * Create a new page with optimized settings */ createOptimizedPage(): Promise<Page>; /** * Cleanup resources */ cleanup(): Promise<void>; } //# sourceMappingURL=PdfEngine.d.ts.map