Table of contents
Namespace: Com\Tecnick\Pdf\Import
class SourceDocument
Source: src/Import/SourceDocument.php:40
Wraps a parsed source PDF document and provides access to its objects and trailer.
Methods
__construct()
Load and parse a PDF from raw binary data.
public __construct(string $data, array<string,mixed> $cfg = [])
Parameters:
$data(string): PDF binary data.$cfg(array<string,mixed>): Parser configuration.
Throws:
- ImportCorruptedSourceException: If the PDF cannot be parsed.
- ImportResourceLimitException: If the nesting depth limit is exceeded, or any limit is reached with ‘strict_limits’.
- ImportUnsupportedFeatureException: If the PDF is encrypted.
Source: src/Import/SourceDocument.php:83
findObject()
Retrieve a specific parsed object by its source reference, or null if it does not exist.
public findObject(string $ref): array<int,mixed>|null
Parameters:
$ref(string): Source object reference.
Returns: array<int,mixed>|null
Source: src/Import/SourceDocument.php:276
getId()
Return the unique document identifier.
public getId(): string
Returns: string: SHA-256 hash of the raw PDF data.
Source: src/Import/SourceDocument.php:225
getObject()
Retrieve a specific parsed object by its source reference (“objnum_generation”).
public getObject(string $ref): array<int,mixed>
Parameters:
$ref(string): Source object reference.
Returns: array<int,mixed>
Throws:
- ImportCorruptedSourceException: If the reference does not exist.
Source: src/Import/SourceDocument.php:261
getParserWarnings()
Return the descriptions of the parsing limits reached while the document was parsed.
public getParserWarnings(): array<int,string>
Returns: array<int,string>
Source: src/Import/SourceDocument.php:205
getTrailer()
Return the trailer array.
public getTrailer(): array<string,mixed>
Returns: array<string,mixed>
Source: src/Import/SourceDocument.php:236
getXref()
Return all xref entries.
public getXref(): array<string,int|string>
Returns: array<string,int|string>
Source: src/Import/SourceDocument.php:246
objectCount()
Return the total number of objects in the parsed document.
public objectCount(): int
Returns: int
Source: src/Import/SourceDocument.php:312
refToKey()
Resolve an indirect reference string (“objnum generation R”) to a source object ref key.
Returns the “objnum_generation” form, e.g. “3_0”.
public static refToKey(string $refStr): string
Parameters:
$refStr(string): Raw reference string from the parsed PDF (e.g. “3 0 R”).
Returns: string: Object ref key (e.g. “3_0”).
Throws:
- ImportCorruptedSourceException: On malformed reference.