@syncfusion/ej2-pdf
Version:
Feature-rich JavaScript PDF library with built-in support for loading and manipulating PDF document.
249 lines (248 loc) • 6.54 kB
TypeScript
import { _TokenType } from './enumerator';
/**
* Parses PDF content streams into record tokens for internal consumption.
*
* @private
*/
export declare class _ContentParser {
/**
* Lexer instance used to tokenize the content stream.
*
* @private
*/
_lexer: _ContentLexer;
/**
* Collected `_PdfRecord` instances parsed from the stream.
*
* @private
*/
_recordCollection: _PdfRecord[];
/**
* Operands collected for the current operator.
*
* @private
*/
_operands: string[];
/**
* Byte buffer for inline image data while parsing.
*
* @private
*/
_inlineImageBytes: number[];
/**
* True when the current operand represents raw inline image bytes.
*
* @private
*/
_isByteOperand: boolean;
constructor(contentStream: number[]);
constructor(contentStream: Uint8Array);
/**
* Read and parse the entire content stream into records.
*
* @private
* @returns {_PdfRecord[]} Array of parsed `_PdfRecord` objects.
*/
_readContent(): _PdfRecord[];
/**
* Parse objects until encountering the specified token type.
*
* @private
* @param {_TokenType} tokenType - Token type that terminates parsing.
* @returns {void} nothing.
*/
_parseObject(tokenType: _TokenType): void;
/**
* Consume and process inline image or operand values from the lexer.
*
* @private
* @returns {void} nothing.
*/
_consumeValue(): void;
/**
* Create a `_PdfRecord` from the current operator and operands and store it.
*
* @private
* @returns {void} nothing.
*/
_createRecord(): void;
/**
* Delegate to the lexer to retrieve the next token type.
*
* @private
* @returns {_TokenType} The next `_TokenType` from the lexer.
*/
_getNextToken(): _TokenType;
}
/**
* Lexer/tokenizer for PDF content streams; intended for internal use.
*
* @private
*/
export declare class _ContentLexer {
/**
* Raw input data for the lexer.
*
* @private
*/
_data: Uint8Array;
/**
* Current token type determined by the lexer.
*
* @private
*/
_tokenType: _TokenType;
/**
* Accumulated operator parameter string for the current token.
*
* @private
*/
_operatorParams: string;
/**
* Current character under consideration.
*
* @private
*/
_currentCharacter: string;
/**
* Next character lookahead used by the lexer.
*
* @private
*/
_nextCharacter: string;
/**
* Current byte offset into `_data`.
*
* @private
*/
_offset: number;
/**
* Text fragments collected while parsing literal strings.
*
* @private
*/
_text: string[];
constructor(data: Uint8Array | number[]);
/**
* Delegate to the lexer to retrieve the next token type.
*
* @private
* @returns {_TokenType} The next `_TokenType` from the lexer.
*/
_getNextToken(): _TokenType;
/**
* Read and discard a comment token.
*
* @private
* @returns {_TokenType} `_TokenType.comment`.
*/
_getComment(): _TokenType;
/**
* Parse a name token starting with '/'.
*
* @private
* @returns {_TokenType} `_TokenType.name` when a name is parsed.
*/
_getName(): _TokenType;
/**
* Parse a numeric token (integer or real).
*
* @private
* @returns {_TokenType} `_TokenType.number`.
*/
_getNumber(): _TokenType;
/**
* Parse an operator token composed of alphabetic/operator characters.
*
* @private
* @returns {_TokenType} `_TokenType.operator`.
*/
_getOperator(): _TokenType;
/**
* Determine whether the provided character is part of an operator token.
*
* @private
* @param {string} value - Single-character string to test.
* @returns {boolean} `true` when the character contributes to an operator.
*/
_isOperator(value: string): boolean;
/**
* Parse a literal or array string token starting with '(' or '['.
*
* @private
* @returns {_TokenType} `_TokenType.string` when parsing completes.
*/
_getLiteralString(): _TokenType;
/**
* Parse an encoded hexadecimal string delimited by '<' and '>'.
*
* @private
* @returns {_TokenType} `_TokenType.hexString`.
*/
_getEncodedDecimalString(): _TokenType;
/**
* Read the contents of a literal string handling escapes and nested parentheses.
*
* @private
* @param {string} value - Initial character to start parsing from.
* @returns {string} The parsed literal string including delimiters.
*/
_getLiteralStringValue(value: string): string;
/**
* Consume the current character into `_operatorParams` and advance.
*
* @private
* @returns {string} The next character after consuming.
*/
_consumeValue(): string;
/**
* Skip whitespace and return the next non-whitespace character.
*
* @private
* @returns {string} The next non-whitespace character.
*/
_moveToNextChar(): string;
/**
* Reset the current offset backwards by `count` bytes.
*
* @private
* @param {number} count - Number of bytes to rewind the offset by.
* @returns {void} nothing.
*/
_resetContentPointer(count: number): void;
/**
* Get the next character when parsing inline image data, with special handling.
*
* @private
* @returns {string} The next character as a string.
*/
_getNextInlineChar(): string;
/**
* Get the next character specifically for inline stream parsing.
*
* @private
* @returns {string} The next character as a string.
*/
_getNextCharForInlineStream(): string;
/**
* Get the next character from the input data, advancing the offset.
*
* @private
* @returns {string} The consumed character as a string.
*/
_getNextChar(): string;
}
/**
* Exactly one of `_operands` or `_inlineImageBytes` will be set based on the
* provided `data` argument.
*
* @private
*/
export declare class _PdfRecord {
_operator: string;
_operands: string[];
_splitText: string[];
_inlineImageBytes: Uint8Array;
constructor(name: string, operands: string[]);
constructor(name: string, imageData: Uint8Array);
}