ImporterInterface

Contract for the PDF import orchestrator.

Namespace: Com\Tecnick\Pdf\Import

interface ImporterInterface

Source: src/Import/ImporterInterface.php: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.

Types

ImportOptions

array{
    box?:               string,
    respectRotation?:   bool,
    groupXObject?:      bool,
    cache?:             bool,
}

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()

Release parser memory and cached resources.

Should be called after getOutImportedObjects() completes.

public cleanUp(): void

Source: src/Import/ImporterInterface.php:156

getOutImportedObjects()

Flush all queued raw PDF object bytes to the output stream.

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

public getOutImportedObjects(): string

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

Source: src/Import/ImporterInterface.php:150

getSourcePageCount()

Return the total number of pages in a registered source document.

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

public getSourcePageCount(string $sourceId): int

Parameters:

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

Returns: int: Total page count.

Throws:

Source: src/Import/ImporterInterface.php:103

getWarnings()

Return the conformance warnings raised while pages were imported.

public getWarnings(): array<int,string>

Returns: array<int,string>

Source: src/Import/ImporterInterface.php:142

importPage()

Import one page from a registered source document and return a PageTemplateInterface.

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).

Returns: PageTemplateInterface: Imported page template.

Throws:

Source: src/Import/ImporterInterface.php:119

importPages()

Import multiple pages from a registered source document.

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

Parameters:

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

Returns: array<int,PageTemplateInterface>: Indexed array, one entry per requested page.

Throws:

Source: src/Import/ImporterInterface.php:135

setImportSourceData()

Register a source PDF from raw binary data and return a stable source identifier.

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

Parameters:

  • $data (string): Raw PDF binary data.
  • $cfg (array<string,mixed>): Optional parser configuration.

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

Throws:

Source: src/Import/ImporterInterface.php:88

setImportSourceFile()

Register a source PDF file and return a stable source identifier.

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.

Returns: string: Source document identifier.

Throws:

Source: src/Import/ImporterInterface.php:71