ImporterInterface

Contract for the PDF import orchestrator. Defining this interface decouples the tc-lib-pdf main library from the concrete import implementation, so the Import\ classes can be extracted into a separate tc-lib-pdf-import package without breaking the public API.

Namespace: Com\Tecnick\Pdf\Import

File: ImporterInterface.php line 53

Contract for the PDF import orchestrator. Defining this interface decouples the tc-lib-pdf main library from the concrete import implementation, so the Import\ classes can be extracted into a separate tc-lib-pdf-import package without breaking the public API.

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-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, }

Methods

cleanUp()

File: ImporterInterface.php line 156

public cleanUp() : void

Should be called after getOutImportedObjects() completes.

getOutImportedObjects()

File: ImporterInterface.php line 150

public getOutImportedObjects() : string

Must be called during the PDF body write phase (after XObjects have been emitted).

Return values

string —

Serialized PDF object bytes ready for appending to the output stream.

getSourcePageCount()

File: ImporterInterface.php line 103

public getSourcePageCount(string $sourceId) : int

The count reflects the pages actually reachable through the /Kids page tree; the declared /Count entry of the /Pages dictionary is ignored.

Parameters

  • $sourceId : string: Source document identifier returned by setImportSource*.

Tags

Return values

int —

Total page count.

getWarnings()

File: ImporterInterface.php line 142

public getWarnings() : array<int, string>

Return values

array<int, string>

importPage()

File: ImporterInterface.php line 119

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: ImporterInterface.php line 135

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 for all pages.
  • $options : array<string, mixed> = []: Import options (same as importPage).

Tags

Return values

array<int, PageTemplateInterface> —

Indexed array, one entry per requested page.

setImportSourceData()

File: ImporterInterface.php line 88

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: ImporterInterface.php line 71

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.