#3748·dompdf

Cpdf and Factur-X

Author: bohwazCreated Aug 24, 2026Updated Aug 24, 2026

I edited the wiki on Factur-X to add a working example, as it bit me that the method did not expect a full XMP file (as Prince and Weasyprint do) but just a XML string that will be included inside the existing XMP file.

Apart from that I could get my Factur-X file generated with DomPDF (after reading #3443) to be validated, so great :) (have you thought about setting up donations through Liberapay? We tried donating through Paypal, but the payment kept failing :( )

Just a small nitpick is that Cpdf::addEmbeddedFile expects a file path. But because I'm also generating the XML file in PHP, I already have it as a string, so storing it on the disk is an extra step that could cost some performance. It would be great to be able to add embedded files from strings as well. For example:

$cpdf->addEmbeddedFileFromString(
  "<?xml…",
  "factur-x.xml",
  "Invoice (Factur-X)",
  "text/xml",
  [$cpdf->catalogId => "Data"]
);

In that case I think the creation and modification date don't have to be included in the PDF header, but it's a detail.