UNPKG

@cantoo/pdf-lib

Version:

Create and modify PDF files with JavaScript

58 lines 2.77 kB
import PDFCrossRefSection from '../document/PDFCrossRefSection'; import PDFHeader from '../document/PDFHeader'; import PDFTrailer from '../document/PDFTrailer'; import PDFTrailerDict from '../document/PDFTrailerDict'; import PDFDict from '../objects/PDFDict'; import PDFObject from '../objects/PDFObject'; import PDFRef from '../objects/PDFRef'; import PDFContext from '../PDFContext'; import PDFSecurity from '../security/PDFSecurity'; import type { DocumentSnapshot } from '../../api/snapshot'; export interface SerializationInfo { size: number; header: PDFHeader; indirectObjects: [PDFRef, PDFObject][]; xref?: PDFCrossRefSection; trailerDict?: PDFTrailerDict; trailer: PDFTrailer; } declare class PDFWriter { static forContext: (context: PDFContext, objectsPerTick: number) => PDFWriter; static forContextWithSnapshot: (context: PDFContext, objectsPerTick: number, snapshot: DocumentSnapshot) => PDFWriter; protected readonly context: PDFContext; protected readonly objectsPerTick: number; protected readonly snapshot: DocumentSnapshot; private parsedObjects; protected constructor(context: PDFContext, objectsPerTick: number, snapshot: DocumentSnapshot); /** * If PDF has an XRef Stream, then the last object will be probably be skipped on saving. * If that's the case, this property will have that object number, and the PDF /Size can * be corrected, to be accurate. */ protected _largestSkippedObjectNum: number; /** * Used to check wheter an object should be saved or not, preserves the object number of the * last XRef Stream object, if there is one. */ protected _lastXRefObjectNumber: number; /** * For incremental saves, defers the decision to the snapshot. * For full saves, checks that the object is not the last XRef stream object. * @param {boolean} incremental If making an incremental save, or a full save of the PDF * @param {number} objNum Object number * @param {[PDFRef, PDFObject][]} objects List of objects that form the PDF * @returns {boolean} whether the object should be saved or not */ protected shouldSave(incremental: boolean, objNum: number, objects: [PDFRef, PDFObject][]): boolean; serializeToBuffer(): Promise<Uint8Array>; protected computeIndirectObjectSize([ref, object]: [ PDFRef, PDFObject ]): number; protected createTrailerDict(prevStartXRef?: number): PDFDict; protected computeBufferSize(incremental: boolean): Promise<SerializationInfo>; protected encrypt(ref: PDFRef, object: PDFObject, security: PDFSecurity): void; protected shouldWaitForTick: (n: number) => boolean; } export default PDFWriter; //# sourceMappingURL=PDFWriter.d.ts.map