Table of contents
Namespace: Com\Tecnick\Pdf\Import
final class DictParser
Source: src/Import/DictParser.php:38
Converts the raw object arrays returned by the PDF parser into PHP associative arrays. Indirect references are left as their raw string values for lazy resolution by the caller.
Methods
objectToArray()
Convert a raw parsed object array to the list of its array value.
Only the first element is examined: an object holding an array opens with the array token, while a stream object can expose trailing tokens when its payload contains an “endstream” marker.
public objectToArray(array<int,mixed> $objData): array<int,mixed>|null
Parameters:
$objData(array<int,mixed>): Raw object data from the parser.
Returns: array<int,mixed>|null: Parsed array elements, or null when the object holds no array.
Source: src/Import/DictParser.php:80
objectToDict()
Convert a raw parsed object array to a dictionary (key => scalar/array).
The first element of the object array whose type is “<<” (dictionary) is extracted.
public objectToDict(array<int,mixed> $objData): array<string,mixed>
Parameters:
$objData(array<int,mixed>): Raw object data from the parser.
Returns: array<string,mixed>
Throws:
- ImportCorruptedSourceException: If no dictionary element is found.
Source: src/Import/DictParser.php:51
parseDictArray()
Recursively convert a raw parser dictionary array into a PHP associative array.
Each entry in the raw array is a pair [key_element, value_element].
public parseDictArray(array<int,mixed> $raw): array<string,mixed>
Parameters:
$raw(array<int,mixed>): Raw dictionary pairs from the parser.
Returns: array<string,mixed>
Source: src/Import/DictParser.php:102
parseValue()
Convert a single raw parser value to a PHP scalar, array, or reference string.
public parseValue(mixed $raw): mixed
Parameters:
$raw(mixed): Raw element from the parser.
Returns: mixed
Source: src/Import/DictParser.php:135
resolveArray()
Resolve a value that may be an indirect reference to an array.
public resolveArray(mixed $value, SourceDocument $src): array<int,mixed>
Parameters:
$value(mixed): Raw value from a parsed dictionary.$src(SourceDocument): Source document the reference belongs to.
Returns: array<int,mixed>: The array items, or an empty array when it cannot be resolved.
Source: src/Import/DictParser.php:227
resolveDict()
Resolve a value that may be an indirect reference to a dictionary.
public resolveDict(mixed $value, SourceDocument $src): array<string,mixed>
Parameters:
$value(mixed): Raw value from a parsed dictionary.$src(SourceDocument): Source document the reference belongs to.
Returns: array<string,mixed>: The dictionary, or an empty array when it cannot be resolved.
Source: src/Import/DictParser.php:191