---
title: "InvoiceReader – API-Referenz · Quittio"
description: "Reads e-invoices from XML or PDF."
canonical_url: "https://quittio.dev/docs/api/Quittio/Core/Reading/InvoiceReader"
locale: de
meta:
  "og:description": "Reads e-invoices from XML or PDF."
  "og:image": "https://quittio.dev/og/quittio-de.jpg"
  "og:image:alt": "Quittio: E-Rechnungen für PHP und Laravel. Rechtssicher, validiert, archiviert, mit geprüfter Beispielrechnung."
  "og:image:height": "630"
  "og:image:type": image/jpeg
  "og:image:width": "1200"
  "og:title": "InvoiceReader – API-Referenz · Quittio"
  "twitter:image": "https://quittio.dev/og/quittio-de.jpg"
  "twitter:image:alt": "Quittio: E-Rechnungen für PHP und Laravel. Rechtssicher, validiert, archiviert, mit geprüfter Beispielrechnung."
---

> Index of every page on this site: [llms.txt](https://quittio.dev/llms.txt)

[API reference](https://quittio.dev/docs/api) / [Quittio](https://quittio.dev/docs/api/Quittio) \\ [Core](https://quittio.dev/docs/api/Quittio/Core) \\ [Reading](https://quittio.dev/docs/api/Quittio/Core/Reading)

# InvoiceReader

final class in quittio/core

`Quittio\Core\Reading\InvoiceReader` · [Source](https://github.com/Quittio/quittio/blob/v0.7.1/packages/core/src/Reading/InvoiceReader.php#L32)

Reads e-invoices from XML or PDF.

Detects the syntax and profile, keeps the declared totals and reports differences to a recalculation instead of correcting them silently.

## Constants \#

| Constant | Value | Description |
| --- | --- | --- |
| `NS_ZUGFERD_1` | `'urn:ferd:CrossIndustryDocument:invoice:1p0'` | Namespace of ZUGFeRD 1.0, which is recognised but not supported. |

## Methods \#

| Method | Description |
| --- | --- |
| `->__construct()` | |
| `::defaultReaders()` | |
| `->read()` | Reads the content (bytes) of an XML or PDF e-invoice. |
| `->readFile()` | Reads an XML or PDF e-invoice from a local file. |
| `->withReader()` | A copy that also tries $reader after the readers so far, e.g. for a national format. |

### `__construct()`#

```
public function __construct(
    list<FormatReader>|null $readers = null,
    ?ProfileRegistry $profiles = null,
    TotalsCalculator $calculator = new \Quittio\Core\Calculation\En16931Calculator(),
    EmbeddedXmlExtractor $pdfExtractor = new \Quittio\Core\Pdf\PdfEmbeddedFileExtractor(),
    int $maxXmlBytes = \Quittio\Core\Xml\XmlSecurity::DEFAULT_MAX_BYTES,
)
```

| Parameter | Type | Description |
| --- | --- | --- |
| `$readers` | `list< [FormatReader](https://quittio.dev/docs/api/Quittio/Core/Reading/FormatReader)>\|null` = `null` | |
| `$profiles` | `? [ProfileRegistry](https://quittio.dev/docs/api/Quittio/Core/Profiles/ProfileRegistry)` = `null` | |
| `$calculator` | `[TotalsCalculator](https://quittio.dev/docs/api/Quittio/Core/Calculation/TotalsCalculator)` = `new \Quittio\Core\Calculation\En16931Calculator()` | |
| `$pdfExtractor` | `[EmbeddedXmlExtractor](https://quittio.dev/docs/api/Quittio/Core/Reading/EmbeddedXmlExtractor)` = `new \Quittio\Core\Pdf\PdfEmbeddedFileExtractor()` | |
| `$maxXmlBytes` | `int` = `\Quittio\Core\Xml\XmlSecurity::DEFAULT_MAX_BYTES` | |

### `defaultReaders()`#

```
public static function defaultReaders(): list<FormatReader>
```

static

<dl><dt>Returns</dt>
<dd><code>list&lt;<a href="https://quittio.dev/docs/api/Quittio/Core/Reading/FormatReader">FormatReader</a>&gt;</code></dd>
</dl>

### `read()`#

```
public function read(string $content): ReadResult
```

Reads the content (bytes) of an XML or PDF e-invoice.

The argument is always treated as content, never as a file name; use readFile() for paths.

| Parameter | Type | Description |
| --- | --- | --- |
| `$content` | `string` | |

<dl><dt>Returns</dt>
<dd><code><a href="https://quittio.dev/docs/api/Quittio/Core/Reading/ReadResult">ReadResult</a></code></dd>
<dt>Throws</dt>
<dd><code><a href="https://quittio.dev/docs/api/Quittio/Core/Xml/UnsafeXmlException">UnsafeXmlException</a></code> – when the XML is too large, not well-formed or not allowed (DOCTYPE, limits)</dd>
<dt>Throws</dt>
<dd><code><a href="https://quittio.dev/docs/api/Quittio/Core/Pdf/PdfException">PdfException</a></code> – when the PDF is too large, encrypted, malformed or exceeds a limit</dd>
<dt>Throws</dt>
<dd><code><a href="https://quittio.dev/docs/api/Quittio/Core/Reading/UnreadableInvoiceException">UnreadableInvoiceException</a></code> – for an unknown format, ZUGFeRD 1.0 or a PDF without an embedded invoice</dd></dl>

### `readFile()`#

```
public function readFile(string $path): ReadResult
```

Reads an XML or PDF e-invoice from a local file.

| Parameter | Type | Description |
| --- | --- | --- |
| `$path` | `string` | |

<dl><dt>Returns</dt>
<dd><code><a href="https://quittio.dev/docs/api/Quittio/Core/Reading/ReadResult">ReadResult</a></code></dd>
<dt>Throws</dt>
<dd><code><a href="https://quittio.dev/docs/api/Quittio/Core/Xml/UnsafeXmlException">UnsafeXmlException</a></code> – when the XML is too large, not well-formed or not allowed (DOCTYPE, limits)</dd>
<dt>Throws</dt>
<dd><code><a href="https://quittio.dev/docs/api/Quittio/Core/Pdf/PdfException">PdfException</a></code> – when the PDF is too large, encrypted, malformed or exceeds a limit</dd>
<dt>Throws</dt>
<dd><code><a href="https://quittio.dev/docs/api/Quittio/Core/Reading/UnreadableInvoiceException">UnreadableInvoiceException</a></code> – for an unknown format, ZUGFeRD 1.0, a PDF without an embedded invoice, or a file that does not exist, is not readable or is too large</dd></dl>

### `withReader()`#

```
public function withReader(FormatReader $reader): self
```

A copy that also tries $reader after the readers so far, e.g. for a national format.

| Parameter | Type | Description |
| --- | --- | --- |
| `$reader` | `[FormatReader](https://quittio.dev/docs/api/Quittio/Core/Reading/FormatReader)` | |

<dl><dt>Returns</dt>
<dd><code>self</code></dd>
</dl>

```json
{"@context":"https://schema.org","@graph":[{"@id":"https://quittio.dev/#website","@type":"WebSite","description":"E-Rechnungen für PHP und Laravel: ZUGFeRD, XRechnung und Peppol erstellen, prüfen, lesen und archivieren.","inLanguage":"de-DE","name":"Quittio","url":"https://quittio.dev/","publisher":{"@id":"https://quittio.dev/#identity"},"workTranslation":{"@id":"https://quittio.dev/en#website"}},{"@id":"https://quittio.dev/docs/api/Quittio/Core/Reading/InvoiceReader#webpage","@type":"WebPage","description":"Reads e-invoices from XML or PDF.","name":"InvoiceReader – API-Referenz","url":"https://quittio.dev/docs/api/Quittio/Core/Reading/InvoiceReader","isPartOf":{"@id":"https://quittio.dev/#website"},"potentialAction":[{"@type":"ReadAction","target":["https://quittio.dev/docs/api/Quittio/Core/Reading/InvoiceReader"]}],"primaryImageOfPage":{"@id":"https://quittio.dev/#logo"}},{"@id":"https://quittio.dev/#identity","@type":"Organization","description":"Open-Source-Bibliothek für E-Rechnungen in PHP und Laravel (ZUGFeRD, XRechnung, Peppol) und Quittio Managed.","email":"kontakt@niklasforst.de","legalName":"Niklas Forst – Softwareentwicklung","name":"Quittio","url":"https://quittio.dev","founder":{"@type":"Person","name":"Niklas Forst","url":"https://quittio.dev/ueber"},"logo":{"@id":"https://quittio.dev/#logo"},"sameAs":["https://github.com/Quittio/quittio","https://packagist.org/packages/quittio/quittio"]},{"@id":"https://quittio.dev/#logo","@type":"ImageObject","caption":"Quittio","contentUrl":"https://quittio.dev/logo.png","inLanguage":"de-DE","url":"https://quittio.dev/logo.png"}]}
```