Table of contents
Namespace: Com\Tecnick\Pdf\Import
class ResourceCloner
Source: src/Import/ResourceCloner.php:43
Deep-copies objects from the source document into the destination PDF using an ObjectMap for reference remapping. Returns serialized PDF object bytes. Streams and strings are encrypted with the key of the destination document.
Methods
__construct()
Constructor.
public __construct(int $pon, int $pdfa = 0, ?Encrypt $encrypt = null)
Parameters:
$pon(int): Current PDF object number (passed by value; read the updated counter back via getPon()).$pdfa(int): PDF/A part of the destination document (0 when PDF/A is not active).$encrypt(?Encrypt): Encryption object of the destination document; a disabled one is used when null.
Throws:
Source: src/Import/ResourceCloner.php:93
cloneResources()
Walk the resource dictionary and enqueue all indirect objects for cloning.
Returns a serialized PDF resource dictionary string with remapped object numbers.
public cloneResources(
array<string,mixed> $resources,
SourceDocument $src,
ObjectMap $map,
int $ownerNum = 0
): string
Parameters:
$resources(array<string,mixed>): Resource dictionary.$src(SourceDocument): Source document.$map(ObjectMap): Object map for reference remapping.$ownerNum(int): Number of the object the dictionary is written into, used as encryption key for the strings it contains.
Returns: string: Serialized PDF resource dictionary, e.g. “<< /Font << /F1 7 0 R » »”, or “<< »” for an empty one.
Throws:
Source: src/Import/ResourceCloner.php:213
enqueueObject()
Clone a referenced source object into the destination document.
public enqueueObject(string $srcRef, SourceDocument $src, ObjectMap $map): int
Parameters:
$srcRef(string): Source object reference key (see SourceDocument::refToKey()).$src(SourceDocument): Source document.$map(ObjectMap): Object map.
Returns: int: Allocated destination object number.
Throws:
Source: src/Import/ResourceCloner.php:369
getContentStream()
Extract the raw bytes of the merged content stream for a page.
Handles a single /Contents reference, an array of references, and a reference to an array of references. Multiple streams are decoded and concatenated into one stream.
public getContentStream(array<string,mixed> $pageDict, SourceDocument $src): array{bytes: string, filter: string, length: int, found: bool}
Parameters:
$pageDict(array<string,mixed>): Effective page dictionary.$src(SourceDocument): Source document.
Returns: array{bytes: string, filter: string, length: int, found: bool}: The ‘found’ flag is false when no content stream object could be located, which is distinct from an empty but valid stream.
Throws:
- ImportCorruptedSourceException: If the content stream cannot be extracted.
- ImportUnsupportedFeatureException: If a filter forbidden by the destination mode survives.
Source: src/Import/ResourceCloner.php:127
getPon()
Return the current object number counter (after any allocations made during cloning).
public getPon(): int
Returns: int