# ZUGFeRD

ZUGFeRD, is a standardized format for electronic invoices. Developed collaboratively by businesses and government entities, ZUGFeRD aims to facilitate seamless and efficient invoicing processes. This standard combines both a human-readable PDF document and structured XML data within a single file, allowing for easy interpretation by both humans and automated systems. ZUGFeRD promotes interoperability and simplifies the exchange of invoices across diverse business systems, fostering a more streamlined and cost-effective invoicing ecosystem. As a widely accepted standard, ZUGFeRD enhances transparency, reduces errors, and contributes to the digital transformation of invoicing practices in Germany and beyond.

While Typeset.sh itself does not offer XML generation functionality, there are alternative packages available to fulfill this need. One such example is <https://github.com/easybill/zugferd-php>.\
\
To attach your XML to the PDF file, setup a save handler designed for this purpose. Refer to the example below for details:

```php
$html = "...";
$xml = "...";

$service = new \Typesetsh\HtmlToPdf();
$service->saveHandler['ZUGFeRD'] = new \Typesetsh\HtmlToPdf\ZUGFeRD($xml);

$result = $service->render($html, \Typesetsh\UriResolver::all());
$result->toFile(__DIR__.'/invoice.pdf');
```

Additional parameters are available if required:

```php
\Typesetsh\HtmlToPdf\ZUGFeRD(
    string $xml,
    string $name = 'factur-x.xml',
    string $description = 'Factur-X/ZUGFeRD Invoice',
    string $type = 'INVOICE',
    string $conformanceLevel = 'BASIC',
    Pdf\Date $modTime = null,
    string $version = '1.0',
)
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.typeset.sh/advanced-guides/pdf-standards/zugferd.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
