horstoeko / zugferd

ZUGFeRD/XRechnung/Factur-X Library
MIT License
176 stars 27 forks source link

[BUG] PDF creation/merge fails #31

Closed WeblinxIT closed 9 months ago

WeblinxIT commented 9 months ago

Describe the bug When I try to merge or create a PDF file with a XML file via ZugferdDocumentPdfMerger or ZugferdDocumentPdfBuilder, I always get the following error: PHP message: PHP Fatal error: Declaration of setasign\\Fpdi\\FpdfTplTrait::setPageFormat($size, $orientation) must be compatible with TCPDF::setPageFormat($format, $orientation = 'P') in /var/www/custom/zugferdxmlbills/includes/setasign/fpdi/src/FpdfTplTrait.php on line 48'

To Reproduce Steps to reproduce the behavior: $pdfMerger = new ZugferdDocumentPdfMerger($xmlfile, $pdfFilename); $pdfMerger->generateDocument(); $pdfMerger->saveDocument('/custom/zugferdxmlbills/temp/'.$invoice->ref.'.pdf'); With an existing XML and PDF file. I get the same error when using the PdfBuilder.

Expected behavior I want to receive a generated PDF file which includes the ZUGFeRD xml

Additional information:

Additional context Thanks for your help.

horstoeko commented 9 months ago

Hi @RunnerLexico

I don't think this is a bug in my library. If you look at the error message:

setasign\\Fpdi\\FpdfTplTrait::setPageFormat($size, $orientation) must be compatible with TCPDF::setPageFormat($format, $orientation = 'P') in

... then there is a problem between "setassign" and "TCPDF". Furthermore, I do not use the mentioned method anywhere in my code. If I do exactly the same, then it works as expected. Unfortunately, the corresponding unit tests in my GitHub actions do not show any errors either. If I see correctly, are you working without Composer? If so, then you have to be extremely careful not to use incompatible product versions. Unfortunately, that's all I can see here at the moment.

Kind regards

WeblinxIT commented 9 months ago

Hi @horstoeko, thanks for your fast response. Yes, I am using compose. Basically I just created a composer file which only includes your library as required as stated in the installation steps: { "config" : { "vendor-dir" : "includes" }, "require" : { "horstoeko/zugferd" : "^1" } } I will test it again with your example files and send you new infos about it when I hae some news.

WeblinxIT commented 9 months ago

Hi @horstoeko,

You were right, it must be a version conflict with composer. I'm using your library within Dolibarr (open source ERP system, based on PHP). Dolibarr uses TCPDF which is used by fpdi/fpdf. Since my module is just a sub module of dolibarr and has its own composer.json I am currently searching for a way to use the "local" tcpdf version which is installed inside my modules directory.

Again, when I have some news I will share them here, if anyone else gets this problem too.

rycks commented 9 months ago

hello @RunnerLexico i already make the dolibarr module for FacturX exports (i'm a dolibarr pref' partner)... please send me your email addr via cap-rel.fr/contact/

Your problem is due to dolibarr point of view: main developers fights against composer as you can see on github

https://github.com/Dolibarr/dolibarr/issues?q=composer

And here is a brief i wrote on french forum about that problem for our modules https://www.dolibarr.fr/forum/t/lirremediable-collision-de-composer-dans-les-modules-complementaires/44936 i think you can use online translators tools to read it ?

horstoeko commented 9 months ago

HI @RunnerLexico

Have you been able to solve the problem in the meantime?

Kind regards

WeblinxIT commented 9 months ago

Hi @horstoeko,

you were totally right with your guess about the version conflict. But till now I didnt manage to solve it due to some changes in my plan regarding my module. I guess we can close that here. But anyway, thank you very much for your support! :)

King regards