import { PDFDict } from '../core/pdf-dict.ts'; import { PDFRef } from '../core/pdf-ref.ts'; import { PDFContext } from './pdf-context.ts'; import type { PDFDocument, UnsafeRenderContext, WriteOptions } from './pdf-document.ts'; import type { PDFResource } from './pdf-resource.ts'; /** * Manages the construction and serialization of a PDF document. */ export declare class DocumentBuilder { private readonly doc; private readonly catalogRef; private readonly onRenderHooks; private written; readonly context: PDFContext; readonly catalog: PDFDict; constructor(doc: PDFDocument); /** * Registers a resource in the document, returning its reference. * If the resource has already been registered, returns the cached reference. */ registerResource(resource: PDFResource): PDFRef; addOnRenderHook(hook: (ctx: UnsafeRenderContext) => void): void; /** * Builds and writes the PDF document, returning the bytes. */ write(opts?: WriteOptions): Uint8Array; private registerPages; private writeHeader; private writeObjects; private writeObjectsWithStreams; /** * Determines if an object can be stored in an object stream. * Objects that cannot be in object streams: * - Stream objects (they have their own stream data) * - Objects with generation number > 0 * - The document catalog (must be directly accessible) * - Encryption dictionaries (not applicable here, but listed for completeness) */ private canBeInObjectStream; private writeXRef; private writeTrailer; private writeXRefStream; private writeXRefStreamTrailer; private resolveXMPMetadata; private registerInfoDict; private buildInfoDict; /** * Generates a unique file identifier for this document. * The ID is a 16-byte random string, used for encryption and file identification. */ private generateFileId; }