import { PDFArray } from '../core/pdf-array.ts'; import { PDFRef } from '../core/pdf-ref.ts'; import type { PDFWriter } from '../core/pdf-writer.ts'; /** * Represents a PDF cross-reference (xref) section, which maps object * numbers to their byte offsets in the PDF file or to object streams. */ export declare class PDFXRefSection { private readonly entries; /** * Constructs a new PDFXRefSection instance. */ constructor(); /** * Adds an entry for an object at a byte offset, or a free entry if deleted. * For free entries, the offset is used as the "next free object number" field. */ addEntry(ref: PDFRef, offset: number, deleted?: boolean): void; /** * Adds a type 2 entry for an object stored in an object stream. * @param ref The reference to the object * @param streamObjNum The object number of the containing object stream * @param index The index of the object within the object stream */ addObjectStreamEntry(ref: PDFRef, streamObjNum: number, index: number): void; /** * Returns true if this section contains any type 2 (object stream) entries. */ hasObjectStreamEntries(): boolean; /** * Writes the xref section as a traditional xref table to the given PDFWriter. * Note: Type 2 entries (object stream references) cannot be represented in * a traditional xref table - use an xref stream instead. */ write(writer: PDFWriter): void; private writeSubsection; /** * Writes the xref section as a compressed xref stream (PDF 1.5+). * The xref stream combines the cross-reference data and trailer into * a single compressed stream object. * * @param writer The PDFWriter to write to * @param lastObjNum The highest object number assigned so far (excluding * the xref stream itself). The xref stream will be assigned the next * object number (`lastObjNum + 1`). * @param trailerEntries Additional trailer dictionary entries (Root, Info, ID, etc.) * @returns The byte offset where the xref stream was written */ writeAsStream(writer: PDFWriter, lastObjNum: number, trailerEntries: { Root: PDFRef; Info?: PDFRef; ID: PDFArray; }, compress?: boolean): number; /** * Builds the binary xref stream data, calculates field widths, and * computes the /Index array if entries are non-contiguous or don't * start at 0. */ private buildXRefStreamData; }