UNPKG

@syncfusion/ej2-pdf

Version:

Feature-rich JavaScript PDF library with built-in support for loading and manipulating PDF document.

1,027 lines (1,026 loc) 36.4 kB
import { _XmlWriter } from './xml-writer'; import { PdfDocument } from './../pdf-document'; import { PdfPage } from './../pdf-page'; import { PdfAnnotation } from './../annotations/annotation'; import { PdfAnnotationCollection } from './../annotations/annotation-collection'; import { _PdfAnnotationType } from './../enumerator'; import { _PdfDictionary, _PdfName, _PdfReference } from './../pdf-primitives'; import { _PdfContentStream } from './../base-stream'; import { _PdfCrossReference } from './../pdf-cross-reference'; import { PdfCheckBoxField, PdfField } from './../form/field'; /** * Provides common helpers for exporting and importing annotations and form fields across formats and manages shared state. * * @private */ export declare abstract class _ExportHelper { exportAppearance: boolean; /** * Determines whether export logic should strictly follow the PDF * specification for field and annotation serialization. * * @private */ _asPerSpecification: boolean; /** * When true, follow specification-specific export behaviors * * @private */ _skipBorderStyle: boolean; /** * File name used during export operations. * * @private */ _fileName: string; /** * The active PDF document being processed. * * @private */ _document: PdfDocument; /** * Cross-reference table for resolving indirect objects. * * @private */ _crossReference: _PdfCrossReference; /** * True when performing an annotation export. * * @private */ _isAnnotationExport: boolean; /** * True when performing an annotation import. * * @private */ _isAnnotationImport: boolean; /** * Internal random key used for some export modes. * * @private */ _key: string; /** * Auxiliary form key appended to rich text values. * * @private */ _formKey: string; /** * When true, export fields even when empty. * * @private */ _exportEmptyFields: boolean; /** * Group name to reference mapping used during export/import. * * @private */ _groupReferences: Map<string, _PdfReference>; /** * Holders for grouped dictionaries queued during processing. * * @private */ _groupHolders: Array<_PdfDictionary>; /** * Encoding dictionary used for text encoding decisions. * * @private */ _encodeDictionary: _PdfDictionary; /** * Requested annotation types for filtered export/import. * * @private */ _annotationTypes: Array<_PdfAnnotationType>; /** * Attributes to include when serializing annotations. * * @private */ _annotationAttributes: Array<string>; /** * Parsed XML document used during import operations. * * @private */ _xmlDocument: Document; /** * Prefix used for embedding rich text payloads. * * @private */ _richTextPrefix: string; /** * DOM parser used to parse incoming XML. * * @private */ _parser: DOMParser; /** * Temporary table mapping field names to exported values. * * @private */ _table: Map<any, any>; /** * Internal map of field name to value arrays gathered during export. * * @private */ _fields: Map<string, string[]>; /** * Rich text values keyed by field name. * * @private */ _richTextValues: Map<string, string>; /** * Working JSON data buffer used during conversion. * * @private */ _jsonData: number[]; /** * ASCII code for '{' * * @private */ _openingBrace: number; /** * ASCII code for '[' * * @private */ _openingBracket: number; /** * ASCII code for '}' * * @private */ _closingBrace: number; /** * ASCII code for ']' * * @private */ _closingBracket: number; /** * ASCII code for ':' * * @private */ _colon: number; /** * ASCII code for '"' * * @private */ _doubleQuotes: number; /** * ASCII code for ',' * * @private */ _comma: number; /** * ASCII code for space * * @private */ _space: number; /** * Current serialization format (e.g., 'XFDF' or 'FDF'). * * @private */ _format: string; /** * Current annotation identifier being processed. * * @private */ _annotationID: string; fdfString: string; /** * True when parsing XFDF into the document. * * @private */ _xmlImport: boolean; /** * Exports annotations using the configured format and returns the serialized bytes. * * @private * @param {PdfDocument} [document] Source PDF document to read annotations. * @returns {Uint8Array} Serialized annotation payload. */ abstract _exportAnnotations(document?: PdfDocument): Uint8Array; /** * Exports form fields using the configured format and returns the serialized bytes. * * @private * @param {PdfDocument} document Source PDF document to read form fields. * @returns {Uint8Array} Serialized form field payload. */ abstract _exportFormFields(document: PdfDocument): Uint8Array; /** * Finalizes the current export operation and returns the serialized bytes. * * @private * @returns {Uint8Array} Serialized output for the active format. */ abstract _save(): Uint8Array; /** * Reads a form field value and stores it in the table using the field name key. * * @private * @param {PdfField} field Field to export. * @returns {string | string[]} Exported value as string or list of strings. */ _exportFormFieldsData(field: PdfField): string | string[]; /** * Exports a single form field and writes its value into the table honoring format rules. * * @private * @param {PdfField} field Field to export. * @returns {void} */ _exportFormFieldData(field: PdfField): void; /** * Gets the annotation subtype name from a dictionary. * * @private * @param {_PdfDictionary} dictionary Annotation dictionary to inspect. * @returns {string} Subtype name or empty string. */ _getAnnotationType(dictionary: _PdfDictionary): string; /** * Converts a PDF primitive into a string suitable for attribute or JSON output. * * @private * @param {any} primitive Primitive to convert. * @param {boolean} [isJson=false] When true emits boolean as true or false otherwise yes or no. * @returns {string} Converted text. */ _getValue(primitive: any, isJson?: boolean): string; /** * Converts an RGB array into a hex color string. * * @private * @param {any} primitive Source color array with three numeric components in the zero to one range. * @returns {string} Hex color string or empty string. */ _getColor(primitive: any): string; /** * Escapes newline and carriage return characters for safe text output. * * @private * @param {string} value Input string to sanitize. * @returns {string} Sanitized string. */ _getValidString(value: string): string; /** * Attempts to resolve a font dictionary used by an annotation appearance for encoding decisions. * * @private * @param {_PdfDictionary} source Source dictionary that may contain appearance resources. * @returns {_PdfDictionary} Font dictionary when found otherwise undefined. */ _getEncodedFontDictionary(source: _PdfDictionary): _PdfDictionary; /** * Encodes a text value using font encoding or document level PDFDocEncoding when available. * * @private * @param {string} value Text to encode. * @param {_PdfDictionary} [dictionary] Optional font resource dictionary to guide encoding. * @returns {string} Encoded text or original text. */ _getEncodedValue(value: string, dictionary?: _PdfDictionary): string; /** * Replaces characters based on differences mapping and font traits to preserve intended glyphs. * * @private * @param {string} input Input text to process. * @param {_FontStructure} structure Font structure containing differences and encoding info. * @returns {string} Updated text after replacement. */ _replaceNotUsedCharacters(input: string, structure: _FontStructure): string; /** * Extracts export value from a primitive or array and adapts it for radio or checkbox fields. * * @private * @param {any} primitive Source primitive to read. * @param {PdfField} [field] Optional field for context such as radio button selection. * @returns {string | string[]} Export value as string or list of strings. */ _getExportValue(primitive: any, field?: PdfField): string | string[]; /** * Registers a reference under a named group and wires reply chains using the NM and IRT entries. * * @private * @param {_PdfReference} reference Reference assigned to the current annotation. * @param {_PdfDictionary} dictionary Annotation dictionary providing NM or IRT entries. * @returns {void} */ _addReferenceToGroup(reference: _PdfReference, dictionary: _PdfDictionary): void; /** * Ensures popup annotations are linked to their parent annotation and updates page collections. * * @private * @param {PdfAnnotationCollection} annotations Annotation collection of the page. * @param {_PdfReference} reference Reference of the parent annotation. * @param {_PdfDictionary} annotationDictionary Parent annotation dictionary. * @param {_PdfDictionary} pageDictionary Page dictionary to update. * @returns {void} */ _handlePopup(annotations: PdfAnnotationCollection, reference: _PdfReference, annotationDictionary: _PdfDictionary, pageDictionary: _PdfDictionary): void; /** * Applies collected field values into the document form fields and writes rich text when present. * * @private * @returns {void} */ _importField(): void; /** * Imports a single form field value or list of values into the target field. * * @private * @param {PdfField} field Target field to update. * @param {string[]} values Values to apply to the field. * @returns {void} */ _importFieldData(field: PdfField, values: string[]): void; /** * Checks whether a checkbox field contains a matching export value. * * @private * @param {string} value Value to test against the field export states. * @param {PdfCheckBoxField} field Target checkbox field. * @returns {boolean} True when the export value is present. */ _containsExportValue(value: string, field: PdfCheckBoxField): boolean; /** * Checks whether a widget dictionary has an appearance state matching the given value. * * @private * @param {_PdfDictionary} dictionary Widget or field dictionary with appearance states. * @param {string} value Appearance state name to test. * @returns {boolean} True when a matching state exists. */ _checkSelected(dictionary: _PdfDictionary, value: string): boolean; /** * Clears all temporary export and import state objects and resets helper properties. * * @private * @returns {void} Clears internal fields used during processing. */ _dispose(): void; } /** * Provides XFDF based export and import utilities for annotations and form fields with XML serialization. * * @private */ export declare class _XfdfDocument extends _ExportHelper { /** * Indicates whether color-space values are included or processed * in the XFDF structure. * * @private */ _isColoSpace: boolean; /** * Initializes the XFDF helper with optional file name for export context. * * @private * @param {string} [fileName] Source or target file name used in XFDF payload. */ constructor(fileName?: string); /** * Prepares and exports annotations from the document as an XFDF byte array. * * @private * @param {PdfDocument} document Source PDF document to read annotations. * @returns {Uint8Array} Generated XFDF payload containing exported annotations. */ _exportAnnotations(document: PdfDocument): Uint8Array; /** * Prepares and exports form fields from the document as an XFDF byte array. * * @private * @param {PdfDocument} document Source PDF document to read form fields. * @returns {Uint8Array} Generated XFDF payload containing exported form fields. */ _exportFormFields(document: PdfDocument): Uint8Array; /** * Serializes the current XFDF document into bytes writing annotations or fields as configured. * * @private * @returns {Uint8Array} Serialized XFDF data. */ _save(): Uint8Array; /** * Writes form field entries into the XML writer honoring Acrobat specification mode. * * @private * @param {_XmlWriter} writer Target XML writer. * @param {boolean} [isAcrobat=false] Indicates Acrobat specific structure should be used. * @returns {void} */ _writeFormFieldData(writer: _XmlWriter, isAcrobat?: boolean): void; /** * Recursively writes nested field elements and their values into the XML writer. * * @private * @param {Map<any, any>} value Nested field map to serialize. * @param {_XmlWriter} writer Target XML writer. * @returns {void} */ _writeFieldName(value: Map<any, any>, writer: _XmlWriter): void; /** * Builds a hierarchical representation of dot separated field names. * * @private * @param {Map<any, any>} table Flat table of field names to values. * @returns {Map<any, any>} Nested map of field groups and values. */ _getElements(table: Map<any, any>): Map<any, any>; /** * Checks whether an annotation matches any requested annotation types. * * @private * @param {PdfAnnotation} annotation Annotation to check. * @returns {boolean} True when the annotation type is allowed. */ _checkAnnotationType(annotation: PdfAnnotation): boolean; /** * Exports a single annotation if it is supported and not a link or uri type. * * @private * @param {PdfAnnotation} annotation Source annotation to export. * @param {_XmlWriter} writer Target XML writer. * @param {number} pageIndex Page index of the annotation. * @returns {void} */ _exportAnnotationData(annotation: PdfAnnotation, writer: _XmlWriter, pageIndex: number): void; /** * Writes annotation data and attributes into XML using either an annotation or its dictionary. * * @private * @param {_XmlWriter} writer Target XML writer. * @param {number} pageIndex Page index of the annotation. * @param {PdfAnnotation|_PdfDictionary} source Annotation instance or annotation dictionary. * @returns {void} */ _writeAnnotationData(writer: _XmlWriter, pageIndex: number, annotation: PdfAnnotation): void; _writeAnnotationData(writer: _XmlWriter, pageIndex: number, dictionary: _PdfDictionary): void; /** * Writes supported dictionary attributes and nested structures into XML for the current annotation. * * @private * @param {_PdfDictionary} dictionary Annotation dictionary to serialize. * @param {number} pageIndex Page index of the annotation. * @param {_XmlWriter} writer Target XML writer. * @param {boolean} hasAppearance Indicates whether appearance streams should be included. * @returns {void} */ _writeDictionary(dictionary: _PdfDictionary, pageIndex: number, writer: _XmlWriter, hasAppearance: boolean): void; /** * Serializes the AP dictionary as a compact XML buffer for embedding in XFDF. * * @private * @param {_PdfDictionary} appearance Appearance dictionary to serialize. * @returns {Uint8Array} XML bytes representing the appearance content. */ _getAppearanceString(appearance: _PdfDictionary): Uint8Array; /** * Traverses an appearance dictionary and writes its content into the XML writer. * * @private * @param {_XmlWriter} writer Target XML writer. * @param {_PdfDictionary} dictionary Appearance dictionary to traverse. * @returns {void} */ _writeAppearanceDictionary(writer: _XmlWriter, dictionary: _PdfDictionary): void; /** * Writes a PDF primitive as a typed XML node handling arrays dictionaries streams names numbers strings and booleans. * * @private * @param {_XmlWriter} writer Target XML writer. * @param {any} primitive Primitive value to serialize. * @param {_PdfDictionary} dictionary Context dictionary for resolving references. * @param {string} [key] Optional key associated with the primitive. * @param {boolean} [isNewReference] Indicates a newly created reference for stream handling. * @returns {void} */ _writeObject(writer: _XmlWriter, primitive: any, dictionary: _PdfDictionary, key?: string, isNewReference?: boolean): void; /** * Starts an XML element for a typed primitive and emits the KEY attribute when present. * * @private * @param {_XmlWriter} writer Target XML writer. * @param {string} name Element name that represents the primitive type. * @param {string} [key] Optional key attribute to write. * @returns {void} */ _writePrefix(writer: _XmlWriter, name: string, key?: string): void; /** * Writes an array of primitives as typed XML nodes. * * @private * @param {_XmlWriter} writer Target XML writer. * @param {any[]} array Source array of primitives. * @param {_PdfDictionary} dictionary Context dictionary for resolving references. * @returns {void} */ _writeArray(writer: _XmlWriter, array: any[], dictionary: _PdfDictionary): void; /** * Normalizes special characters for XML content depending on direction of conversion. * * @private * @param {string} value Input string to normalize. * @param {boolean} [isParsing=false] True when normalizing from XML to plain text. * @returns {string} Normalized string with suitable entity substitutions. */ _getFormatedString(value: string, isParsing?: boolean): string; /** * Maps a dictionary entry into XML attributes writing known keys and formats. * * @private * @param {_XmlWriter} writer Target XML writer. * @param {string} key Dictionary key to process. * @param {any} primitive Source primitive value. * @returns {void} */ _writeAttribute(writer: _XmlWriter, key: string, primitive: any): void; /** * Writes a single attribute with string conversion and optional lowercase normalization. * * @private * @param {_XmlWriter} writer Target XML writer. * @param {string} attribute Attribute name to write. * @param {any} primitive Source primitive value. * @param {boolean} [isLowerCase=false] When true writes value in lowercase. * @returns {void} */ _writeAttributeString(writer: _XmlWriter, attribute: string, primitive: any, isLowerCase?: boolean): void; /** * Writes an element with raw XML content when value is already formatted. * * @private * @param {_XmlWriter} writer Target XML writer. * @param {string} name Element name to create. * @param {string} value Raw XML content to inject. * @returns {void} */ _writeRawData(writer: _XmlWriter, name: string, value: string): void; /** * Writes color attributes and optional numeric component into the XML writer. * * @private * @param {_XmlWriter} writer Target XML writer. * @param {any} primitive Source color primitive array number or name. * @param {string} attribute Attribute name for color output. * @param {string} [tag] Optional attribute for numeric component. * @returns {void} */ _writeColor(writer: _XmlWriter, primitive: any, attribute: string, tag?: string): void; /** * Exports measurement dictionary properties and writes formatted sub dictionaries to XML. * * @private * @param {_PdfDictionary} dictionary Source measure dictionary to export. * @param {_XmlWriter} writer Target XML writer. * @returns {void} */ _exportMeasureDictionary(dictionary: _PdfDictionary, writer: _XmlWriter): void; /** * Writes a single measurement sub dictionary as attribute set into the XML writer. * * @private * @param {_PdfDictionary} measurementDetails Measurement dictionary to serialize. * @param {_XmlWriter} writer Target XML writer. * @returns {void} */ _exportMeasureFormatDetails(measurementDetails: _PdfDictionary, writer: _XmlWriter): void; /** * Imports annotations from XFDF bytes and appends them to the document. * * @private * @param {PdfDocument} document Target PDF document to receive annotations. * @param {Uint8Array} data UTF8 encoded XFDF bytes. * @returns {void} */ _importAnnotations(document: PdfDocument, data: Uint8Array): void; /** * Imports form field values from XFDF bytes and applies them to the document form. * * @private * @param {PdfDocument} document Target PDF document to receive form values. * @param {Uint8Array} data UTF8 encoded XFDF bytes. * @returns {void} */ _importFormData(document: PdfDocument, data: Uint8Array): void; /** * Reads the root XML element and routes to annotation or form import handlers. * * @private * @param {HTMLElement} root Root element of the XFDF document. * @returns {void} */ _readXmlData(root: HTMLElement): void; /** * Validates the root XFDF element name. * * @private * @param {HTMLElement} element Root element to validate. * @returns {void} * @throws {Error} When the file is not a valid XFDF document. */ _checkXfdf(element: HTMLElement): void; /** * Parses XFDF form data section and populates the internal fields table. * * @private * @param {HTMLElement} root Root element containing form fields. * @returns {void} */ _parseFormData(root: HTMLElement): void; /** * Flattens a list of nested field elements into the internal fields table with full names. * * @private * @param {Element[]} list List of field elements to parse. * @returns {void} */ _importFormNodes(list: Element[]): void; /** * Builds the fully qualified field name by walking up the form field hierarchy. * * @private * @param {Element} node Field element from which to derive the full name. * @returns {string} Fully qualified field name (e.g., "parent.child.subchild"). */ _getFieldName(node: Element): string; /** * Parses a single annotation element and adds it to the corresponding page. * * @private * @param {Element} element Annotation element to parse. * @returns {void} */ _parseAnnotationData(element: Element): void; /** * Builds an annotation dictionary from an XML element and its attributes and children. * * @private * @param {PdfPage} page Page that will host the annotation. * @param {Element} element Annotation element to convert. * @returns {_PdfDictionary} Constructed annotation dictionary or empty on unsupported type. */ _getAnnotationDictionary(page: PdfPage, element: Element): _PdfDictionary; /** * Adds general annotation attributes border style inner elements and measure data to a dictionary. * * @private * @param {_PdfDictionary} dictionary Destination dictionary to update. * @param {Element} element Source annotation element. * @param {PdfPage} page Page that will host the annotation. * @returns {void} */ _addAnnotationData(dictionary: _PdfDictionary, element: Element, page: PdfPage): void; /** * Applies border style attributes from an element to the annotation dictionary. * * @private * @param {_PdfDictionary} dictionary Destination annotation dictionary. * @param {Element} element Source annotation element with style attributes. * @returns {void} */ _addBorderStyle(dictionary: _PdfDictionary, element: Element): void; /** * Converts element attributes into corresponding dictionary entries for supported keys. * * @private * @param {_PdfDictionary} dictionary Destination annotation dictionary. * @param {NamedNodeMap} attributes Attribute collection from the source element. * @returns {void} */ _applyAttributeValues(dictionary: _PdfDictionary, attributes: NamedNodeMap): void; /** * Parses a comma separated numeric list into an array of numbers. * * @private * @param {string} value Comma separated numeric list. * @returns {number[]} Parsed numeric array. */ _obtainPoints(value: string): number[]; /** * Parses child nodes like popup contents appearance inklist vertices and embedded data. * * @private * @param {_PdfDictionary} dictionary Destination annotation dictionary. * @param {Element} element Source annotation element to inspect. * @param {PdfPage} page Page context used for nested annotation parsing. * @returns {void} */ _parseInnerElements(dictionary: _PdfDictionary, element: Element, page: PdfPage): void; /** * Adds embedded stream data for sound or file attachment annotations. * * @private * @param {Node} child Data node that contains stream bytes. * @param {_PdfDictionary} dictionary Destination annotation dictionary. * @param {Element} parent Parent annotation element for attribute context. * @returns {void} */ _addStreamData(child: Node, dictionary: _PdfDictionary, parent: Element): void; /** * Creates a sound stream and links it to the annotation dictionary using provided attributes. * * @private * @param {_PdfDictionary} dictionary Destination annotation dictionary. * @param {Element} element Data element with sound attributes. * @param {number[]} raw Raw byte array for sound data. * @returns {void} */ _addSound(dictionary: _PdfDictionary, element: Element, raw: number[]): void; /** * Creates an embedded file stream and filespec dictionary and links them to the annotation. * * @private * @param {_PdfDictionary} dictionary Destination annotation dictionary. * @param {Element} element Data element with file attributes. * @param {number[]} raw Raw byte array for file data. * @returns {void} */ _addFileAttachment(dictionary: _PdfDictionary, element: Element, raw: number[]): void; /** * Decodes appearance XML from base64 and assigns it to the annotation AP dictionary. * * @private * @param {Node} element * @param {Node} element Appearance element containing encoded XML. * @param {_PdfDictionary} dictionary Destination annotation dictionary. * @returns {void} */ _addAppearanceData(element: Node, dictionary: _PdfDictionary): void; /** * Parses a typed appearance node and adds the resulting primitive to the target dictionary or stream. * * @private * @param {_PdfDictionary|_PdfContentStream} source Destination dictionary or content stream. * @param {Node} child Typed node to parse such as STREAM DICT ARRAY DATA or scalar. * @returns {void} */ _getAppearance(source: _PdfDictionary | _PdfContentStream, child: Node): void; /** * Creates an empty content stream and populates it with parsed appearance entries. * * @private * @param {Element} element Stream element to parse. * @returns {_PdfContentStream} Constructed content stream. */ _getStream(element: Element): _PdfContentStream; /** * Creates a dictionary and populates it with parsed appearance entries. * * @private * @param {Element} element Dictionary element to parse. * @returns {_PdfDictionary} Constructed dictionary. */ _getDictionary(element: Element): _PdfDictionary; /** * Parses an ARRAY node into a JavaScript array of primitives and references. * * @private * @param {Element} element Array element to parse. * @returns {any} Parsed array value. */ _getArray(element: Element): any; /** * Parses a DATA node into a raw byte array based on declared mode and encoding. * * @private * @param {Element} element Data node with MODE and ENCODING attributes. * @returns {number[]} Parsed byte array. */ _getData(element: Element): number[]; /** * Appends a typed child element value into the given array. * * @private * @param {any} array Destination array for parsed items. * @param {Node} child Typed node to parse and append. * @returns {void} */ _addArrayElements(array: any, child: Node): void; /** * Reads a FIXED element into a number. * * @private * @param {Element} element Fixed element with VAL attribute. * @returns {number} Parsed floating point value. */ _getFixed(element: Element): number; /** * Reads an INT element into a number. * * @private * @param {Element} element Int element with VAL attribute. * @returns {number} Parsed integer value. */ _getInt(element: Element): number; /** * Reads a STRING element into a text value. * * @private * @param {Element} element String element with VAL attribute. * @returns {string} Parsed string value. */ _getString(element: Element): string; /** * Reads a NAME element into a PDF name object. * * @private * @param {Element} element Name element with VAL attribute. * @returns {_PdfName} Parsed name object. */ _getName(element: Element): _PdfName; /** * Reads a BOOL element into a boolean value. * * @private * @param {Element} element Bool element with VAL attribute. * @returns {boolean} Parsed boolean value. */ _getBoolean(element: Element): boolean; /** * Builds and attaches the Measure dictionary to the annotation based on nested measure elements. * * @private * @param {_PdfDictionary} dictionary Destination annotation dictionary. * @param {Element} element Annotation element containing measure data. * @returns {void} */ _addMeasureDictionary(dictionary: _PdfDictionary, element: Element): void; /** * Copies supported measurement attributes from an element into a measurement dictionary. * * @private * @param {Element} element Measurement element containing attributes. * @param {_PdfDictionary} dictionary Destination measurement dictionary. * @returns {void} */ _addElements(element: Element, dictionary: _PdfDictionary): void; /** * Updates a dictionary with a string value when present. * * @private * @param {_PdfDictionary} dictionary Destination dictionary to update. * @param {string} key Entry key to set. * @param {string} value String value to store. * @returns {void} */ _addString(dictionary: _PdfDictionary, key: string, value: string): void; /** * Updates a dictionary with an integer value when present. * * @private * @param {_PdfDictionary} dictionary Destination dictionary to update. * @param {string} key Entry key to set. * @param {string} value String numeric text to convert. * @returns {void} */ _addInt(dictionary: _PdfDictionary, key: string, value: string): void; /** * Updates a dictionary with a floating point value when present. * * @private * @param {_PdfDictionary} dictionary Destination dictionary to update. * @param {string} key Entry key to set. * @param {string} value String numeric text to convert. * @returns {void} */ _addFloat(dictionary: _PdfDictionary, key: string, value: string): void; /** * Updates a dictionary with an array of numbers when present. * * @private * @param {_PdfDictionary} dictionary Destination dictionary to update. * @param {number[]} points Numeric array to store. * @param {string} key Entry key to set. * @returns {void} */ _addFloatPoints(dictionary: _PdfDictionary, points: number[], key: string): void; /** * Adds a parsed primitive to a dictionary using the KEY attribute of the XML element. * * @private * @param {any} primitive Parsed primitive to store. * @param {_PdfDictionary} dictionary Destination dictionary to update. * @param {Element} element Source element containing the KEY attribute. * @returns {void} */ _addKey(primitive: any, dictionary: _PdfDictionary, element: Element): void; /** * Applies line ending styles from attributes head and tail to the annotation dictionary. * * @private * @param {_PdfDictionary} dictionary Destination annotation dictionary. * @param {Element} element Source annotation element with head and tail. * @returns {void} */ _addLineEndStyle(dictionary: _PdfDictionary, element: Element): void; } /** * Extracts font metadata and encoding details from a font dictionary and provides convenient accessors. * * @private */ export declare class _FontStructure { /** * Source font dictionary backing this helper. * * @private */ _dictionary: _PdfDictionary; /** * Cached mapping of character code differences to glyph names. * * @private */ _differencesDictionary: Map<string, string>; /** * Resolved font subtype (e.g., 'Type1', 'TrueType'). * * @private */ _fontType: string; /** * Base encoding name when present on the font's encoding dictionary. * * @private */ _baseFontEncoding: string; /** * Computed font encoding name normalized for processing. * * @private */ _fontEncoding: string; /** * Resolved internal font name used for lookups. * * @private */ _fontName: string; /** * Creates a font structure helper bound to a font dictionary. * * @private * * @param {_PdfDictionary} dictionary Source font dictionary. */ constructor(dictionary: _PdfDictionary); readonly differencesDictionary: Map<string, string>; readonly baseFontEncoding: string; readonly fontEncoding: string; readonly fontName: string; /** * Resolves the font encoding from the font dictionary and normalizes identity encodings. * * @private * @returns {string} Resolved encoding name. */ _getFontEncoding(): string; /** * Builds a differences dictionary mapping character codes to characters using the font encoding. * * @private * @returns {Map<string, string>} Differences dictionary. */ _getDifferencesDictionary(): Map<string, string>; /** * Extracts and normalizes the font name by removing subsets styles and hex sequences. * * @private * @returns {string} Normalized font name. */ _getFontName(): string; /** * Decodes hex escape sequences in a font name into unicode characters. * * @private * @param {string} fontName Encoded font name containing hash based hex sequences. * @returns {string} Decoded font name. */ _decodeHexFontName(fontName: string): string; }