Importer

Orchestrates PDF import: loads source documents, resolves pages, clones resources, builds Form XObjects, and registers them for deferred output via getOutImportedObjects().

Namespace: Com\Tecnick\Pdf\Import

Implements: ImporterInterface

File: Importer.php line 50

Orchestrates PDF import: loads source documents, resolves pages, clones resources, builds Form XObjects, and registers them for deferred output via getOutImportedObjects().

Tags

Methods

__construct()

File: Importer.php line 148

public __construct(array<string, mixed> &$xobjects, int &$pon, File $file[, int $pdfa = 0 ][, Encrypt|null $encrypt = null ][, bool $requireEmbeddedFonts = false ]) : mixed

Parameters

  • $xobjects : array<string, mixed>: Reference to the destination document’s xobjects array.
  • $pon : int: Reference to the PDF object number counter.
  • $file : File: Shared file helper instance.
  • $pdfa : int = 0: PDF/A part of the destination document (0 when not active).
  • $encrypt : Encrypt|null = null: Encryption object of the destination document; a disabled one is used when null.
  • $requireEmbeddedFonts : bool = false: True when the destination document requires every font to be embedded.

Tags

  • throws: Exception

cleanUp()

File: Importer.php line 495

public cleanUp() : void

Should be called after getOutImportedObjects() completes.

getOutImportedObjects()

File: Importer.php line 480

public getOutImportedObjects() : string

Called from getOutPDFBody() after getOutXObjects().

Return values

string —

Serialized PDF object bytes.

getSourcePageCount()

File: Importer.php line 278

public getSourcePageCount(string $sourceId) : int

The count is derived from the page tree reachable through /Kids. The declared /Count entry is ignored: it is controlled by the source file and never sizes an allocation or bounds a loop.

Parameters

  • $sourceId : string: Source document identifier.

Tags

Return values

int —

Total page count.

getWarnings()

File: Importer.php line 171

public getWarnings() : array<int, string>

Return values

array<int, string>

importPage()

File: Importer.php line 299

public importPage(string $sourceId, int $pageNum[, array<string, mixed> $options = [] ]) : PageTemplateInterface

Parameters

  • $sourceId : string: Source document identifier.
  • $pageNum : int: 1-based page number.
  • $options : array<string, mixed> = []: Import options (box, groupXObject, cache, respectRotation).

Tags

Return values

PageTemplateInterface

Imported page template.

importPages()

File: Importer.php line 444

public importPages(string $sourceId[, array<string|int, int>|null $range = null ][, array<string, mixed> $options = [] ]) : array<int, PageTemplateInterface>

Parameters

  • $sourceId : string: Source document identifier.
  • $range : array<string|int, int>|null = null: 1-based page numbers to import, or null to import all pages.
  • $options : array<string, mixed> = []: Import options (same as importPage).

Tags

Return values

array<int, PageTemplateInterface> —

Indexed array of PageTemplate, one per requested page.

setImportSourceData()

File: Importer.php line 252

public setImportSourceData(string $data[, array<string, mixed> $cfg = [] ]) : string

Parameters

  • $data : string: Raw PDF binary data.
  • $cfg : array<string, mixed> = []: Optional parser configuration.

Tags

Return values

string —

Source document identifier (SHA-256 of the data).

setImportSourceFile()

File: Importer.php line 221

public setImportSourceFile(string $path[, array<string, mixed> $cfg = [] ]) : string

Parameters

  • $path : string: File path to a readable PDF.
  • $cfg : array<string, mixed> = []: Optional parser configuration.

Tags

Return values

string —

Source document identifier.