Table of contents
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
- throws: ImportSourceNotFoundException If the source ID is not registered.
- throws: ImportCorruptedSourceException If the page tree is malformed.
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
- throws: ImportSourceNotFoundException If the source ID is not registered.
- throws: ImportPageOutOfRangeException If the page number is out of range.
- throws: ImportCorruptedSourceException If the page tree is malformed.
- throws: ImportUnsupportedFeatureException If an unsupported feature is encountered.
Return values
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
- throws: ImportSourceNotFoundException If the source ID is not registered.
- throws: ImportPageOutOfRangeException If any page number is out of range.
- throws: ImportCorruptedSourceException If the page tree is malformed.
- throws: ImportUnsupportedFeatureException If an unsupported feature is encountered.
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
- phpstan-param: ParserOptions|array<string, mixed> $cfg
- throws: ImportCorruptedSourceException If the data cannot be parsed.
- throws: ImportResourceLimitException If the nesting depth limit is exceeded, or any limit is reached with ‘strict_limits’.
- throws: ImportUnsupportedFeatureException If the source is encrypted.
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
- phpstan-param: ParserOptions|array<string, mixed> $cfg
- throws: ImportSourceNotFoundException If the file cannot be read.
- throws: ImportCorruptedSourceException If the file cannot be parsed.
- throws: ImportResourceLimitException If the nesting depth limit is exceeded, or any limit is reached with ‘strict_limits’.
- throws: ImportUnsupportedFeatureException If the source is encrypted.
Return values
string —
Source document identifier.