/** * PDF Object Model * * This implementation mirrors the Rust `pdf::object` module for 100% API compatibility. */ import { PdfObjectType } from '../types.js'; /** * Base class for all PDF objects */ export declare abstract class PdfObject { private _refCount; private _marked; private _parentNum; abstract get type(): PdfObjectType; get isNull(): boolean; get isBool(): boolean; get isInt(): boolean; get isReal(): boolean; get isNumber(): boolean; get isString(): boolean; get isName(): boolean; get isArray(): boolean; get isDict(): boolean; get isStream(): boolean; get isIndirect(): boolean; /** * Increment reference count (keep object alive) */ keep(): this; /** * Decrement reference count (may allow garbage collection) */ drop(): void; /** * Get current reference count */ getRefs(): number; /** * Check if object is marked */ isMarked(): boolean; /** * Mark this object */ mark(): void; /** * Unmark this object */ unmark(): void; /** * Set parent object number (for indirect objects) */ setParent(objNum: number): void; /** * Get parent object number */ getParentNum(): number; toBool(): boolean; toInt(): number; toReal(): number; toNumber(): number; toString(): string; toName(): string; nameEquals(name: string): boolean; abstract equals(other: PdfObject): boolean; } /** * PDF Array object */ export declare class PdfArray extends PdfObject { private readonly items; private dirty; constructor(items?: PdfObject[]); get type(): PdfObjectType; /** * Get the number of elements in the array */ get length(): number; /** * Get element at the specified index */ get(index: number): PdfObject | undefined; /** * Set element at the specified index (alias for put) */ put(index: number, obj: PdfObject): void; /** * Push a PDF object to the end of the array */ push(obj: PdfObject): void; /** * Push an integer value to the end of the array */ pushInt(value: number): void; /** * Push a real (float) value to the end of the array */ pushReal(value: number): void; /** * Push a boolean value to the end of the array */ pushBool(value: boolean): void; /** * Push a name to the end of the array */ pushName(value: string): void; /** * Push a string to the end of the array */ pushString(value: string): void; /** * Insert element at the specified index */ insert(index: number, obj: PdfObject): void; /** * Delete element at the specified index */ delete(index: number): void; /** * Convert to a JavaScript array */ toArray(): PdfObject[]; /** * Check if this array has been modified */ isDirty(): boolean; /** * Mark this array as dirty (modified) */ markDirty(): void; /** * Mark this array as clean (not modified) */ markClean(): void; /** * Create a shallow copy of this array */ copy(): PdfArray; /** * Create a deep copy of this array */ deepCopy(): PdfArray; [Symbol.iterator](): Iterator; equals(other: PdfObject): boolean; } /** * PDF Dictionary object */ export declare class PdfDict extends PdfObject { private readonly entries; private dirty; constructor(entries?: Record); get type(): PdfObjectType; /** * Get the number of entries in the dictionary */ get length(): number; /** * Get value for a key */ get(key: string): PdfObject | undefined; /** * Put a PDF object value for a key */ put(key: string, value: PdfObject): void; /** * Put an integer value for a key */ putInt(key: string, value: number): void; /** * Put a real (float) value for a key */ putReal(key: string, value: number): void; /** * Put a boolean value for a key */ putBool(key: string, value: boolean): void; /** * Put a name for a key */ putName(key: string, value: string): void; /** * Put a string for a key */ putString(key: string, value: string): void; /** * Delete a key from the dictionary */ del(key: string): void; /** * Check if a key exists in the dictionary */ has(key: string): boolean; /** * Get all keys in the dictionary */ keys(): string[]; /** * Get all values in the dictionary */ values(): PdfObject[]; /** * Get all entries as [key, value] pairs */ getEntries(): [string, PdfObject][]; [Symbol.iterator](): Generator<[string, PdfObject]>; /** * Get name value for a key */ getName(key: string): string; /** * Get string value for a key */ getString(key: string): string; /** * Get integer value for a key */ getInt(key: string, defaultValue?: number): number; /** * Get real (float) value for a key */ getReal(key: string, defaultValue?: number): number; /** * Get boolean value for a key */ getBool(key: string, defaultValue?: boolean): boolean; /** * Get array for a key */ getArray(key: string): PdfArray | undefined; /** * Get dictionary for a key */ getDict(key: string): PdfDict | undefined; /** * Get stream for a key */ getStream(key: string): PdfStream | undefined; /** * Check if this dictionary has been modified */ isDirty(): boolean; /** * Mark this dictionary as dirty (modified) */ markDirty(): void; /** * Mark this dictionary as clean (not modified) */ markClean(): void; /** * Create a shallow copy of this dictionary */ copy(): PdfDict; /** * Create a deep copy of this dictionary */ deepCopy(): PdfDict; equals(other: PdfObject): boolean; } /** * PDF Stream object */ export declare class PdfStream extends PdfObject { readonly dict: PdfDict; private _data; constructor(dict: PdfDict, data?: Uint8Array); get type(): PdfObjectType; /** * Get the stream data */ getData(): Uint8Array; /** * Set the stream data */ setData(data: Uint8Array): void; /** * Get the stream dictionary */ getDict(): PdfDict; /** * Create a deep copy of this stream */ deepCopy(): PdfStream; equals(other: PdfObject): boolean; } /** * PDF Indirect Reference object */ export declare class PdfIndirectRef extends PdfObject { readonly objNum: number; readonly genNum: number; constructor(objNum: number, genNum?: number); get type(): PdfObjectType; equals(other: PdfObject): boolean; } /** * Create a null PDF object */ export declare function pdfNull(): PdfObject; /** * Create a boolean PDF object */ export declare function pdfBool(value: boolean): PdfObject; /** * Create an integer PDF object */ export declare function pdfInt(value: number): PdfObject; /** * Create a real PDF object */ export declare function pdfReal(value: number): PdfObject; /** * Create a string PDF object */ export declare function pdfString(value: string): PdfObject; /** * Create a name PDF object */ export declare function pdfName(value: string): PdfObject; /** * Create an array PDF object */ export declare function pdfArray(items?: PdfObject[]): PdfArray; /** * Create a dictionary PDF object */ export declare function pdfDict(entries?: Record): PdfDict; /** * Compare two PDF objects for equality */ export declare function pdfObjectCompare(a: PdfObject, b: PdfObject): boolean; /** * Check if a PDF name equals a string value */ export declare function pdfNameEquals(obj: PdfObject, name: string): boolean; /** * Create a deep copy of a PDF object */ export declare function pdfDeepCopy(obj: PdfObject): PdfObject; /** * Create a shallow copy of an array */ export declare function pdfCopyArray(array: PdfArray): PdfArray; /** * Create a shallow copy of a dictionary */ export declare function pdfCopyDict(dict: PdfDict): PdfDict; /** * Check if object is null */ export declare function isNull(obj: PdfObject): boolean; /** * Check if object is a boolean */ export declare function isBool(obj: PdfObject): boolean; /** * Check if object is an integer */ export declare function isInt(obj: PdfObject): boolean; /** * Check if object is a real number */ export declare function isReal(obj: PdfObject): boolean; /** * Check if object is a number (int or real) */ export declare function isNumber(obj: PdfObject): boolean; /** * Check if object is a name */ export declare function isName(obj: PdfObject): boolean; /** * Check if object is a string */ export declare function isString(obj: PdfObject): boolean; /** * Check if object is an array */ export declare function isArray(obj: PdfObject): boolean; /** * Check if object is a dictionary */ export declare function isDict(obj: PdfObject): boolean; /** * Check if object is a stream */ export declare function isStream(obj: PdfObject): boolean; /** * Check if object is an indirect reference */ export declare function isIndirect(obj: PdfObject): boolean; /** * Convert object to boolean with default value */ export declare function toBoolDefault(obj: PdfObject | undefined, defaultValue: boolean): boolean; /** * Convert object to integer with default value */ export declare function toIntDefault(obj: PdfObject | undefined, defaultValue: number): number; /** * Convert object to real with default value */ export declare function toRealDefault(obj: PdfObject | undefined, defaultValue: number): number; /** * Get object number from indirect reference */ export declare function toObjNum(obj: PdfObject): number; /** * Get generation number from indirect reference */ export declare function toGenNum(obj: PdfObject): number; /** * Increment reference count on object */ export declare function pdfKeepObj(obj: PdfObject): PdfObject; /** * Decrement reference count on object */ export declare function pdfDropObj(obj: PdfObject): void; /** * Get reference count for object */ export declare function pdfObjRefs(obj: PdfObject): number; /** * Check if object is marked */ export declare function pdfObjMarked(obj: PdfObject): boolean; /** * Mark an object */ export declare function pdfMarkObj(obj: PdfObject): void; /** * Unmark an object */ export declare function pdfUnmarkObj(obj: PdfObject): void; /** * Set parent object number */ export declare function pdfSetObjParent(obj: PdfObject, parentNum: number): void; /** * Get parent object number */ export declare function pdfObjParentNum(obj: PdfObject): number; /** * Create a point dictionary (for use in PDF objects) */ export declare function pdfNewPoint(x: number, y: number): PdfArray; /** * Create a rectangle dictionary (for use in PDF objects) */ export declare function pdfNewRect(x0: number, y0: number, x1: number, y1: number): PdfArray; /** * Create a matrix dictionary (for use in PDF objects) */ export declare function pdfNewMatrix(a: number, b: number, c: number, d: number, e: number, f: number): PdfArray; /** * Create a date string in PDF format * Format: D:YYYYMMDDHHmmSSOHH'mm */ export declare function pdfNewDate(date?: Date): PdfObject; /** * Get key at index from dictionary (for iteration) */ export declare function pdfDictGetKey(dict: PdfDict, index: number): string | undefined; /** * Get value at index from dictionary (for iteration) */ export declare function pdfDictGetVal(dict: PdfDict, index: number): PdfObject | undefined; /** * Check if an indirect reference is resolved * @param obj The object to check * @returns Always true for direct objects, requires document context for indirect refs */ export declare function pdfObjIsResolved(obj: PdfObject): boolean; /** * Resolve an indirect reference (stub - requires document context) * @param obj The object to resolve * @returns The same object (actual resolution requires document) */ export declare function pdfResolveIndirect(obj: PdfObject): PdfObject; /** * Load an object from document (stub - requires document context) * @param objNum Object number * @param genNum Generation number * @returns undefined (actual loading requires document) */ export declare function pdfLoadObject(_objNum: number, _genNum: number): PdfObject | undefined; //# sourceMappingURL=object.d.ts.map