Zum Inhalt springen

API reference / Quittio \ Core \ Pdf

PdfEmbeddedFileExtractor

final class in quittio/core · implements DiagnosingXmlExtractor

Quittio\Core\Pdf\PdfEmbeddedFileExtractor · Source

Extracts the embedded invoice XML from PDF files (ZUGFeRD 2.x, Factur-X, XRechnung in PDF).

Embedded files are searched in the associated files of the document (/AF, PDF/A-3) and in the name tree (/Names /EmbeddedFiles). Classic cross-reference tables, cross-reference streams and object streams are supported. All structures are limited (tree size, number of file specifications, decompressed size) as protection against malicious files, and file names are never used as paths.

Constants#

ConstantValueDescription
KNOWN_FILENAMES['factur-x.xml', 'xrechnung.xml', 'zugferd-invoice.xml', 'ZUGFeRD-invoice.xml']Known file names in order of preference (ZUGFeRD-invoice.xml is the ZUGFeRD 1.0 name).

Methods#

MethodDescription
->__construct()
->extract()
->extractFile()
->maxPdfBytes()
->names()Names of all embedded files.

__construct()#

public function __construct(
    int $maxPdfBytes = 25 * 1024 * 1024,
    int $maxDecompressedBytes = 50 * 1024 * 1024,
)
ParameterTypeDescription
$maxPdfBytesint = 25 * 1024 * 1024
$maxDecompressedBytesint = 50 * 1024 * 1024

extract()#

public function extract(string $pdf): ?array
ParameterTypeDescription
$pdfstring
Returns
?array

extractFile()#

public function extractFile(string $pdf): ?ExtractedXml
ParameterTypeDescription
$pdfstring
Returns
?ExtractedXml

maxPdfBytes()#

public function maxPdfBytes(): int
Returns
int

names()#

public function names(string $pdf): list<string>

Names of all embedded files.

ParameterTypeDescription
$pdfstring
Returns
list<string>

Die Open-Core-Pakete stehen unter der MIT-Lizenz. Die rechtlichen Formulierungen der Länderpakete sind mit einer Steuerberatung abzustimmen.