tecnickcom / TCPDF

Official clone of PHP library to generate PDF documents and barcodes
https://tcpdf.org
Other
4.22k stars 1.52k forks source link

How to add a file into the PDF, without adding annotation? #578

Open thierryler opened 1 year ago

thierryler commented 1 year ago

Hello,

To create an invoice, using the factur-x format, I need to embed an XML file into the PDF. The only way, i've founded was to add an annotation:

$pdf->Annotation(0,0,0,0, 'invoice', array(
    'Subtype' => 'FileAttachment', 
    'Name'    => 'PushPin', 
    'FS'      => 'factur-x.xml'
));

But: 1) that adds an useless annotation 2) the file appears twice (in the file list) when I open the PDF with Accrobat Reader

Is there a way to simply add the file, without annotation?

Thx Th.

williamdes commented 1 year ago

Can you provide a validation tool for this format? And share specs for this format? I honestly do not know the answer to your question but may have a look if the spec about this format is interesting :)

thierryler commented 1 year ago

Hello,

The factur-x format is the new format for invoices. It will be required in France and Germany in 2024.

In factur-x, you have your standard PDF and an xml file embeded.

You can find specification here : http://fnfe-mpe.org/factur-x/

But the question is actually not only for factur-x. It about how to add a file into the PDF, not using anotations.

Here is a screen capture. You can see that the xml file is included twice. And that also adds a useless anotation.

Capture d’écran 2022-12-29 à 14 10 36
williamdes commented 1 year ago

Thanks, I am in France, that's good to know

Sure I understood that the issue is about embedding a file in the pdf

thierryler commented 1 year ago

@williamdes Je suis beta testeur pour la facture électronique. Elle sera obligatoire pour les grandes entreprises en 2024, mais par extension, toutes les petites entreprises qui achètent ou vendent avec les grosses vont devoir s'y mettre aussi. Et ça promet d'être un beau bazar...

The org also referencies this lib https://github.com/atgp/factur-x which allow to merge a PDF with a xml file.

williamdes commented 1 year ago

@williamdes Je suis beta testeur pour la facture électronique. Elle sera obligatoire pour les grandes entreprises en 2024, mais par extension, toutes les petites entreprises qui achètent ou vendent avec les grosses vont devoir s'y mettre aussi. Et ça promet d'être un beau bazar...

The org also referencies this lib https://github.com/atgp/factur-x which allow to merge a PDF with a xml file.

Oui hihihi, déjà les clients disent que c'est pas pressé On est pas sorti de ce bordel..

Essayons d'être en avance cette fois ci

williamdes commented 7 months ago

Via dompdf y a du progrès ! https://github.com/dompdf/dompdf/issues/3443

IgitBuh commented 2 months ago

I face the same challenge and was hoping the latest version of TCPDF would offer a solution for this. Did you find a proper solution in the meantime? Would it be possible to create the required XML and attach it to the PDF with this extension? http://www.fpdf.org/en/script/script95.php