@syncfusion/ej2-pdf
Version:
Feature-rich JavaScript PDF library with built-in support for loading and manipulating PDF document.
555 lines (554 loc) • 17.8 kB
TypeScript
import { _PdfAbstractSyntaxElement } from './abstract-syntax';
import { _ConstructionType, _TagClassType } from './enumerator';
import { _PdfCharacterString } from './character-string';
import { _PdfUniqueEncodingElement } from './unique-encoding-element';
/**
* Basic BER/DER encoding element providing encoding/decoding helpers for primitive and constructed types.
*
* @private
*/
export declare class _PdfBasicEncodingElement extends _PdfAbstractSyntaxElement {
/**
* Preferred length encoding to use when serializing this element.
*
* @private
*/
_lengthEncodingPreference: _EncodingLength;
/**
* Internal storage for this element's value; may be raw bytes or child elements.
*/
private _value;
/**
* Cached current computed value length when available.
*/
private _currentValueLength;
/**
* ASCII code for period `.` used by string parsing helpers.
*
* @private
*/
_period: number;
/**
* ASCII code for comma `,` used by string parsing helpers.
*
* @private
*/
_comma: number;
/**
* ASCII code for `Z` used by time/date parsing helpers.
*
* @private
*/
_z: number;
/**
* ASCII code for plus `+` used by time/date parsing helpers.
*
* @private
*/
_plus: number;
/**
* ASCII code for minus `-` used by time/date parsing helpers.
*
* @private
*/
_minus: number;
/**
* Initializes a basic encoding element with optional tag class, construction, tag number and value.
*
* @private
* @param {_TagClassType} tagClass The tag class for the element.
* @param {_ConstructionType} construction Whether the element is primitive or constructed.
* @param {number} tagNumber The numeric tag number.
* @param {any} value Optional initial value to encode.
*/
constructor(tagClass?: _TagClassType, construction?: _ConstructionType, tagNumber?: number, value?: any);
/**
* Returns the raw value bytes for this element, encoding constructed content if necessary.
*
* @private
* @returns {Uint8Array} The raw value bytes.
*/
_getValue(): Uint8Array;
/**
* Sets the raw value bytes for this element and updates cached length.
*
* @private
* @param {Uint8Array} value The value bytes to assign.
* @returns {void} nothing.
*/
_setValue(value: Uint8Array): void;
/**
* Decodes and returns the boolean value for this element.
*
* @private
* @returns {boolean} The decoded boolean.
*/
_getBooleanValue(): boolean;
/**
* Encodes and sets a boolean value for this element.
*
* @private
* @param {boolean} value The boolean to set.
* @returns {void} nothing.
*/
_setBooleanValue(value: boolean): void;
/**
* Returns the bit string content for this element, concatenating parts if constructed.
*
* @private
* @returns {Uint8ClampedArray} The bit string.
*/
_getBitString(): Uint8ClampedArray;
/**
* Encodes and sets a bit string value for this element.
*
* @private
* @param {Uint8ClampedArray} value The bit string to assign.
* @returns {void} nothing.
*/
_setBitString(value: Uint8ClampedArray): void;
/**
* Returns the octet string bytes for this element.
*
* @private
* @returns {Uint8Array} The octet string bytes.
*/
_getOctetString(): Uint8Array;
/**
* Sets the octet string value for this element.
*
* @private
* @param {Uint8Array} value The octet string bytes to assign.
* @returns {void} nothing.
*/
_setOctetString(value: Uint8Array): void;
/**
* Returns the object descriptor string for this element.
*
* @private
* @returns {string} The object descriptor.
*/
_getObjectDescriptor(): string;
/**
* Encodes and sets the object descriptor string for this element.
*
* @private
* @param {string} value The descriptor to assign.
* @returns {void} nothing.
*/
_setObjectDescriptor(value: string): void;
/**
* Returns the UTF-8 string value for this element.
*
* @private
* @returns {string} The UTF-8 decoded string.
*/
_getUtf8String(): string;
/**
* Sets the UTF-8 string value for this element.
*
* @private
* @param {string} value The UTF-8 string to assign.
* @returns {void} nothing.
*/
_setUtf8String(value: string): void;
/**
* Returns the sequence child elements for this constructed element.
*
* @private
* @returns {_PdfAbstractSyntaxElement[]} The sequence elements.
*/
_getSequence(): _PdfAbstractSyntaxElement[];
/**
* Sets the sequence child elements for this element and marks it constructed.
*
* @private
* @param {_PdfAbstractSyntaxElement[]} value The sequence elements to assign.
* @returns {void} nothing.
*/
_setSequence(value: _PdfAbstractSyntaxElement[]): void;
/**
* Returns the elements for an abstract SET value after uniqueness validation.
*
* @private
* @returns {_PdfAbstractSyntaxElement[]} The set elements.
*/
_getAbstractSetValue(): _PdfAbstractSyntaxElement[];
/**
* Sets the elements for an abstract SET value.
*
* @private
* @param {_PdfAbstractSyntaxElement[]} value The set elements to assign.
* @returns {void} nothing.
*/
_setAbstractSetValue(value: _PdfAbstractSyntaxElement[]): void;
/**
* Returns the elements when this is a `SEQUENCE OF`.
*
* @private
* @returns {_PdfAbstractSyntaxElement[]} The sequence-of elements.
*/
_getSequenceOf(): _PdfAbstractSyntaxElement[];
/**
* Sets the elements when this is a `SEQUENCE OF` and marks constructed.
*
* @private
* @param {_PdfAbstractSyntaxElement[]} value The elements to assign.
* @returns {void} nothing.
*/
_setSequenceOf(value: _PdfAbstractSyntaxElement[]): void;
/**
* Returns the elements when this is a `SET OF`.
*
* @private
* @returns {_PdfAbstractSyntaxElement[]} The set-of elements.
*/
_getAbstractSetOf(): _PdfAbstractSyntaxElement[];
/**
* Sets the elements when this is a `SET OF`.
*
* @private
* @param {_PdfAbstractSyntaxElement[]} value The elements to assign.
* @returns {void} nothing.
*/
_setAbstractSetOf(value: _PdfAbstractSyntaxElement[]): void;
/**
* Returns the numeric string value for this element.
*
* @private
* @returns {string} The numeric string.
*/
_getNumericString(): string;
/**
* Sets the numeric string value for this element.
*
* @private
* @param {string} value The numeric string to assign.
* @returns {void} nothing.
*/
_setNumericString(value: string): void;
/**
* Returns the printable string value for this element.
*
* @private
* @returns {string} The printable string.
*/
_getPrintableString(): string;
/**
* Sets the printable string value for this element.
*
* @private
* @param {string} value The printable string to assign.
* @returns {void} nothing.
*/
_setPrintableString(value: string): void;
/**
* Returns teleprinter (Teletex) text bytes for this element.
*
* @private
* @returns {Uint8Array} The teleprinter bytes.
*/
_getTeleprinterText(): Uint8Array;
/**
* Sets teleprinter (Teletex) text bytes for this element.
*
* @private
* @param {Uint8Array} value The bytes to assign.
* @returns {void} nothing.
*/
_setTeleprinterText(value: Uint8Array): void;
/**
* Returns videotex information bytes for this element.
*
* @private
* @returns {Uint8Array} The videotex bytes.
*/
_getVideoTextInformation(): Uint8Array;
/**
* Sets videotex information bytes for this element.
*
* @private
* @param {Uint8Array} value The bytes to assign.
* @returns {void} nothing.
*/
_setVideoTextInformation(value: Uint8Array): void;
/**
* Returns the IA5 (international alphabet) string for this element.
*
* @private
* @returns {string} The IA5 string.
*/
_getInternationalAlphabetString(): string;
/**
* Sets the IA5 (international alphabet) string for this element.
*
* @private
* @param {string} value The IA5 string to assign.
* @returns {void} nothing.
*/
_setInternationalAlphabetString(value: string): void;
/**
* Returns the graphic string for this element.
*
* @private
* @returns {string} The graphic string.
*/
_getGraphicString(): string;
/**
* Sets the graphic string value for this element.
*
* @private
* @param {string} value The graphic string to assign.
* @returns {void} nothing.
*/
_setGraphicString(value: string): void;
/**
* Returns the visible string for this element.
*
* @private
* @returns {string} The visible string.
*/
_getVisibleString(): string;
/**
* Sets the visible string value for this element.
*
* @private
* @param {string} value The visible string to assign.
* @returns {void} nothing.
*/
_setVisibleString(value: string): void;
/**
* Returns the general string for this element.
*
* @private
* @returns {string} The general string.
*/
_getGeneralString(): string;
/**
* Sets a character string (complex structure) for this element and marks it constructed.
*
* @private
* @param {_PdfCharacterString} value The character string structure to assign.
* @returns {void} nothing.
*/
_setCharacterString(value: _PdfCharacterString): void;
/**
* Returns the universal (UTF-32) string for this element.
*
* @private
* @returns {string} The universal string.
*/
_getUniversalString(): string;
/**
* Sets the universal (UTF-32) string for this element.
*
* @private
* @param {string} value The universal string to assign.
* @returns {void} nothing.
*/
_setUniversalString(value: string): void;
/**
* Returns the BMP (UTF-16BE) string for this element.
*
* @private
* @returns {string} The BMP string.
*/
_getBmpString(): string;
/**
* Sets the BMP (UTF-16BE) string for this element.
*
* @private
* @param {string} value The BMP string to assign.
* @returns {void} nothing.
*/
_setBmpString(value: string): void;
/**
* Constructs this element from provided child elements (internal helper).
*
* @private
* @param {_PdfAbstractSyntaxElement[]} els The child elements to set.
* @returns {void} nothing.
*/
_construct(els: _PdfAbstractSyntaxElement[]): void;
/**
* Encodes a JavaScript value into the appropriate ASN.1 encoding for this element.
*
* @private
* @param {any} value The value to encode.
* @returns {void} nothing.
*/
_encode(value: any): void;
/**
* Wraps a BER sequence into a `_PdfBasicEncodingElement` representing a SEQUENCE.
*
* @private
* @param {_PdfAbstractSyntaxElement[]} sequence The sequence elements.
* @returns {_PdfBasicEncodingElement} The constructed sequence element.
*/
_fromBerSequence(sequence: (_PdfAbstractSyntaxElement)[]): _PdfBasicEncodingElement;
/**
* Wraps a set of basic encoding elements into a `_PdfBasicEncodingElement` representing a SET.
*
* @private
* @param {_PdfBasicEncodingElement[]} set The set elements.
* @returns {_PdfBasicEncodingElement} The constructed set element.
*/
_fromSet(set: (_PdfBasicEncodingElement)[]): _PdfBasicEncodingElement;
/**
* Wraps a set-of elements into a `_PdfBasicEncodingElement` representing a SET OF.
*
* @private
* @param {_PdfBasicEncodingElement[]} set The set-of elements.
* @returns {_PdfBasicEncodingElement} The constructed set-of element.
*/
_fromSetOf(set: (_PdfBasicEncodingElement)[]): _PdfBasicEncodingElement;
/**
* Retrieves the single inner element for explicitly-encoded elements.
*
* @private
* @param {boolean} [isCertificateParsing] Optional flag to relax trailing bytes validation.
* @returns {_PdfAbstractSyntaxElement} The inner element.
*/
_getInner(isCertificateParsing?: boolean): _PdfAbstractSyntaxElement;
/**
* Sets a single inner element and marks this element as constructed.
*
* @private
* @param {_PdfAbstractSyntaxElement} value The inner element to assign.
* @returns {void} nothing.
*/
_setInner(value: _PdfAbstractSyntaxElement): void;
/**
* Decodes this element from the provided BER/DER bytes and returns number of bytes consumed.
*
* @private
* @param {Uint8Array} bytes The input bytes to decode.
* @returns {number} The number of bytes consumed.
*/
_fromBytes(bytes: Uint8Array): number;
/**
* Computes the number of bytes required to encode the length field for a value length.
*
* @private
* @param {number} [valueLength] Optional explicit value length to evaluate.
* @returns {number} The number of bytes used to encode the length.
*/
_lengthLength(valueLength?: number): number;
/**
* Returns the length in bytes of this element's encoded value.
*
* @private
* @returns {number} The value length.
*/
_valueLength(): number;
/**
* Produces the tag and length bytes for this element.
*
* @private
* @returns {Uint8Array} The tag-and-length bytes.
*/
_tagAndLengthBytes(): Uint8Array;
/**
* Serializes this element into an array of buffers representing tag, length and value parts.
*
* @private
* @returns {Uint8Array[]} Array of buffers.
*/
_toBuffers(): Uint8Array[];
/**
* Serializes constructed content into a single value buffer for the provided data type hint.
*
* @private
* @param {string} dataType A textual hint for the data type being serialized.
* @returns {Uint8Array} The serialized value bytes.
*/
_serialize(dataType: string): Uint8Array;
/**
* Returns the component elements when this element represents constructed content.
*
* @private
* @returns {_PdfAbstractSyntaxElement[]} Component elements.
*/
_getComponents(): _PdfAbstractSyntaxElement[];
/**
* Decodes an ASN.1 BIT STRING from bytes into a bit array.
*
* @private
* @param {Uint8Array} value The bytes to decode.
* @returns {Uint8ClampedArray} The decoded bit array.
*/
_decodeBitString(value: Uint8Array): Uint8ClampedArray;
/**
* Decodes an ASN.1 BOOLEAN from bytes.
*
* @private
* @param {Uint8Array} value The bytes to decode.
* @returns {boolean} The decoded boolean.
*/
_decodeBoolean(value: Uint8Array): boolean;
/**
* Decodes a sequence of basic encoding elements from bytes.
*
* @private
* @param {Uint8Array} value The bytes to decode.
* @returns {_PdfBasicEncodingElement[]} Decoded elements.
*/
_decodedSequence(value: Uint8Array): _PdfBasicEncodingElement[];
/**
* Determines the numeric base used for REAL encoding from a control byte.
*
* @private
* @param {number} byte The control byte to inspect.
* @returns {number} The numeric base (2, 8, or 16).
*/
_getRealEncodingBase(byte: number): number;
/**
* Encodes a `_PdfCharacterString` structure into bytes suitable for this element.
*
* @private
* @param {_PdfCharacterString} value The character-string structure to encode.
* @returns {Uint8Array} The encoded bytes.
*/
_encodeCharacterString(value: _PdfCharacterString): Uint8Array;
/**
* Decodes a sequence of unique encoding elements from bytes.
*
* @private
* @param {Uint8Array} value The bytes to decode.
* @returns {_PdfUniqueEncodingElement[]} Decoded unique elements.
*/
_decodeSequence(value: Uint8Array): _PdfUniqueEncodingElement[];
/**
* Wraps a sequence of abstract syntax elements into a unique encoding element.
*
* @private
* @param {_PdfAbstractSyntaxElement[]} sequence The sequence elements.
* @returns {_PdfUniqueEncodingElement} The wrapped unique element.
*/
_fromSequence(sequence: (_PdfAbstractSyntaxElement)[]): _PdfUniqueEncodingElement;
/**
* Returns the external encoding represented by an encoding element, mapping tag options to values.
*
* @private
* @param {_PdfAbstractSyntaxElement} encodingElement The encoding element describing the external.
* @returns {_PdfAbstractSyntaxElement|Uint8Array|Uint8ClampedArray} The decoded external payload.
*/
_getExternalEncoding(encodingElement: _PdfAbstractSyntaxElement): _PdfAbstractSyntaxElement | Uint8Array | Uint8ClampedArray;
/**
* Returns the total encoded length of this element including tag and length fields.
*
* @private
* @returns {number} The combined tag+length+value length in bytes.
*/
_tagValueLength(): number;
}
/**
* Represents the internal encoding length type used for defining whether the structure
* uses definite or indefinite length encoding.
*
* @private
*/
export declare enum _EncodingLength {
definite = 0,
indefinite = 1
}