/** * **Optional jsPDF-backed PDF exporter.** * * The officially-supported way to produce `.pdf` output. Like the Excel * adapter it lives on its own entry point, is absent from the core barrel, and * never names `jspdf` or `jspdf-autotable` in an import — the host passes both * in, so Photon Grid Core stays at zero runtime dependencies: * * ```ts * import jsPDF from 'jspdf'; * import autoTable from 'jspdf-autotable'; * import { registerExporter } from 'photon-grid-core'; * import { createPdfExporter } from 'photon-grid-core/export/pdf'; * * registerExporter('pdf', createPdfExporter({ jsPDF, autoTable })); * await grid.api.export('pdf', { fileName: 'employees.pdf', orientation: 'landscape' }); * ``` * * Pagination, header repetition on every page and text wrapping are all * delegated to `jspdf-autotable`, which already solves them properly; this * adapter's job is to map Photon Grid's {@link PreparedExportData} and * {@link PdfExportOptions} onto it, and to keep large exports from being * pathological (see {@link PDF_ROW_WARNING_THRESHOLD}). * * @packageDocumentation */ import type { GridExporter, PdfExportOptions } from '../export.types'; /** Text-drawing and page bookkeeping used for the title and page numbers. */ export interface JsPdfDocument { internal: { pageSize: { getWidth(): number; getHeight(): number; }; pages?: unknown[]; }; setFontSize(size: number): unknown; text(text: string, x: number, y: number, options?: { align?: string; }): unknown; getNumberOfPages(): number; setPage(page: number): unknown; save(fileName: string): unknown; } /** Construction options this adapter passes to `new jsPDF(...)`. */ export interface JsPdfConstructorOptions { orientation?: string; unit?: string; format?: string; } /** The `jspdf` default export — a constructor. */ export type JsPdfConstructor = new (options?: JsPdfConstructorOptions) => JsPdfDocument; /** The subset of `jspdf-autotable`'s options this adapter sets. */ export interface AutoTableOptions { head?: string[][]; body?: string[][]; startY?: number; margin?: { top?: number; right?: number; bottom?: number; left?: number; }; theme?: string; styles?: Record; headStyles?: Record; bodyStyles?: Record; alternateRowStyles?: Record; columnStyles?: Record>; showHead?: string | boolean; didDrawPage?: (data: unknown) => void; } /** The `jspdf-autotable` default export. */ export type AutoTableFn = (doc: JsPdfDocument, options: AutoTableOptions) => void; /** The libraries a host hands to {@link createPdfExporter}. */ export interface PdfExporterDeps { /** The `jspdf` default export (the `jsPDF` constructor). */ readonly jsPDF: JsPdfConstructor; /** The `jspdf-autotable` default export. */ readonly autoTable: AutoTableFn; /** * Extra `jspdf-autotable` options merged **under** the ones this adapter * derives — the seam for host branding (fonts, colours, cell hooks) without * the core's option types ever naming a jsPDF type. */ readonly autoTableDefaults?: AutoTableOptions; } /** * Row count beyond which the adapter warns once. * * jsPDF renders the whole document in memory; tens of thousands of rows will * produce a very large file and can stall the tab. The export is **not** * truncated — silently dropping rows would be worse than a slow file — but the * host is told, so it can scope the export or offer Excel instead. */ export declare const PDF_ROW_WARNING_THRESHOLD = 20000; /** * Builds a PDF {@link GridExporter} bound to host-supplied jsPDF libraries. * * @param deps - `jsPDF` and `autoTable`, plus optional `jspdf-autotable` defaults. * @returns An exporter ready for `registerExporter('pdf', …)`. * @throws {TypeError} When either library is missing — a clear failure at * registration beats an opaque one at export time. */ export declare function createPdfExporter(deps: PdfExporterDeps): GridExporter; //# sourceMappingURL=pdf-exporter.d.ts.map