PdfEmbeddedFileExtractor
in package
implements
DiagnosingXmlExtractor
FinalYes
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.
Table of Contents
Interfaces
- DiagnosingXmlExtractor
- An extractor that also reports where the XML came from and what it noticed on the way.
Constants
- KNOWN_FILENAMES : array<string|int, mixed> = ['factur-x.xml', 'xrechnung.xml', 'zugferd-invo...
- Known file names in order of preference (ZUGFeRD-invoice.xml is the ZUGFeRD 1.0 name).
Methods
- __construct() : mixed
- extract() : array{0: string, 1: string}|null
- extractFile() : ExtractedXml|null
- maxPdfBytes() : int
- names() : array<int, string>
- Names of all embedded files.
Constants
KNOWN_FILENAMES
Known file names in order of preference (ZUGFeRD-invoice.xml is the ZUGFeRD 1.0 name).
public
array<string|int, mixed>
KNOWN_FILENAMES
= ['factur-x.xml', 'xrechnung.xml', 'zugferd-invoice.xml', 'ZUGFeRD-invoice.xml']
Methods
__construct()
public
__construct([int $maxPdfBytes = 25 * 1024 * 1024 ][, int $maxDecompressedBytes = 50 * 1024 * 1024 ]) : mixed
Parameters
- $maxPdfBytes : int = 25 * 1024 * 1024
- $maxDecompressedBytes : int = 50 * 1024 * 1024
extract()
public
extract(string $pdf) : array{0: string, 1: string}|null
Parameters
- $pdf : string
Return values
array{0: string, 1: string}|null —file name and XML content, or null if none is embedded
extractFile()
public
extractFile(string $pdf) : ExtractedXml|null
Parameters
- $pdf : string
Return values
ExtractedXml|nullmaxPdfBytes()
public
maxPdfBytes() : int
Return values
intnames()
Names of all embedded files.
public
names(string $pdf) : array<int, string>
Parameters
- $pdf : string