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 59

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

Tags

  • since: 2026-05-03
  • category: Library
  • author: Nicola Asuni info@tecnick.com
  • copyright: 2002-2026 Nicola Asuni - Tecnick.com LTD
  • license: https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
  • link: https://github.com/tecnickcom/tc-lib-pdf
  • phpstan-import-type: TXOBject from \Com\Tecnick\Pdf\Base
  • phpstan-type: ImportOptions array{ box?: string, respectRotation?: bool, groupXObject?: bool, cache?: bool, }
  • phpstan-type: ParserOptions array{ ignore_filter_errors?: bool, decode_streams?: bool, strict_limits?: bool, max_stream_size?: int, max_resolution_depth?: int, max_nesting_depth?: int, }
  • SuppressWarnings: (“CouplingBetweenObjects”)

Methods

__construct()

File: Importer.php line 157

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 579

public cleanUp() : void

Should be called after getOutImportedObjects() completes.

getOutImportedObjects()

File: Importer.php line 564

public getOutImportedObjects() : string

Called from getOutPDFBody() after getOutXObjects().

Return values

string —

Serialized PDF object bytes.

getSourcePageCount()

File: Importer.php line 359

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 180

public getWarnings() : array<int, string>

Return values

array<int, string>

importPage()

File: Importer.php line 380

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 528

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 315

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 280

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.