/** * PDF object parser. * * Parses PDF tokens into typed PDF objects: dictionaries, arrays, strings, * numbers, booleans, names, null, indirect references, and streams. * * @see PDF Reference 1.7, Chapter 3 - Objects */ import type { Token, PdfTokenizer } from "./pdf-tokenizer.js"; /** A PDF indirect object reference: `N gen R` */ export interface PdfRef { readonly type: "ref"; readonly objNum: number; readonly gen: number; } /** A PDF stream: dictionary + raw data bytes */ export interface PdfStream { readonly type: "stream"; readonly dict: PdfDictValue; readonly data: Uint8Array; } /** A PDF dictionary: key-value pairs where keys are names */ export type PdfDictValue = Map; /** A PDF array */ export type PdfArrayValue = PdfObject[]; /** * Union type for all possible PDF object values. */ export type PdfObject = number | string | boolean | null | Uint8Array | PdfRef | PdfDictValue | PdfArrayValue | PdfStream; export declare function isPdfRef(obj: PdfObject | undefined): obj is PdfRef; export declare function isPdfStream(obj: PdfObject | undefined): obj is PdfStream; export declare function isPdfDict(obj: PdfObject | undefined): obj is PdfDictValue; export declare function isPdfArray(obj: PdfObject | undefined): obj is PdfArrayValue; /** Get a string value from a PDF dictionary */ export declare function dictGetName(dict: PdfDictValue, key: string): string | undefined; /** Get a number value from a PDF dictionary */ export declare function dictGetNumber(dict: PdfDictValue, key: string): number | undefined; /** Get a boolean value from a PDF dictionary */ export declare function dictGetBool(dict: PdfDictValue, key: string): boolean | undefined; /** Get a dictionary value from a PDF dictionary */ export declare function dictGetDict(dict: PdfDictValue, key: string): PdfDictValue | undefined; /** Get an array value from a PDF dictionary */ export declare function dictGetArray(dict: PdfDictValue, key: string): PdfArrayValue | undefined; /** Get a ref from a PDF dictionary */ export declare function dictGetRef(dict: PdfDictValue, key: string): PdfRef | undefined; /** Get bytes (string as Uint8Array) from a PDF dictionary */ export declare function dictGetBytes(dict: PdfDictValue, key: string): Uint8Array | undefined; /** Get a string value that may be either a name (string) or bytes decoded as latin1 */ export declare function dictGetString(dict: PdfDictValue, key: string): string | undefined; /** * Decode PDF string bytes to a JavaScript string. * Handles UTF-16BE (BOM = FEFF) and PDFDocEncoding (Latin-1 superset). */ export declare function decodePdfStringBytes(bytes: Uint8Array): string; /** * Parse a single PDF object from the tokenizer. * * Handles all PDF object types including dictionaries (with possible streams), * arrays, strings, numbers, names, booleans, null, and indirect references. */ export declare function parseObject(tokenizer: PdfTokenizer): PdfObject; /** * Parse a PDF object given the first token has already been consumed. */ export declare function parseObjectFromToken(tokenizer: PdfTokenizer, token: Token): PdfObject;