admin管理员组文章数量:1431904
I am trying to create an invoice pdf with ZUGFeRD format on my site. After customer placing his order, the order information should be saved in ZUGFeRD xml file and then create invoice pdf file which has the xml file as an attachment. The project is built with MERN stack. I tried to find solutions online but there we only JAVA and C# built-in libraries. Is there any library for javascript projects to handle ZUGFeRD invoicing? If it needs to be built from the ground up, which steps should be needed?
Thank you for your advice!
I am trying to create an invoice pdf with ZUGFeRD format on my site. After customer placing his order, the order information should be saved in ZUGFeRD xml file and then create invoice pdf file which has the xml file as an attachment. The project is built with MERN stack. I tried to find solutions online but there we only JAVA and C# built-in libraries. Is there any library for javascript projects to handle ZUGFeRD invoicing? If it needs to be built from the ground up, which steps should be needed?
Thank you for your advice!
Share Improve this question asked Jun 30, 2022 at 0:47 Zhukov AdamZhukov Adam 231 silver badge3 bronze badges2 Answers
Reset to default 3Since the xml is to ply with Zugferd/Factur-X then it is a very specialist embed to match the standards. Hevierweight Java or C# is required for speed, though you could mand line from any script outside of restricted HTML.js
This is European Plutocracy at its finest, only those controlling money will pay each other. For a wider code orientated usage definition see https://duckduckgo./?q=EN+%2B16931
The key coding elements shown here. Are a strictly defined XML input (4 page on right in example) (could have been much simpler written as ODT) is processesed to generate a 100% synchronized colour PDF output (1 page in example on left) Which then in turn must include the 100% verifiable XML source and colour profile plus fonts!, all wrapped into one PDFA archive (could have been simpler if as just one Zipped.docX but was not to be!).
XML embedded in PDF for extract and process
You will need to ensure your XML matches the PDF data with respect to layout and that is entirely down to customer customization, so nobody here can guide on that step. However, it then (IMHO stupidly) requires a precise bination of colour profile and matching colour setting!, those can be auto templated for mand line insertion, but you must get it right once, so its repeatable.
Thus you should be able to do it using Ghostscript and read carefully https:/ghostscript./blog/zugferd.html however Ghostscript should naturally be licensed by you for your mercial use.
For an alternative Java based Open Source up to date project see the Mustang Project
It is not a lightweight read in either case, but for patibly consider both tools and pare.
Reading is quite easy, you can use pdf.js's getAttachments() functionality as demonstrated in our e-invoice viewer Quba, https://github./ZUGFeRD/quba-viewer/blob/master/app/main.js .
The issue with writing is that need to embed a file into a PDF/A-3+ structure, which works with Ghostscript, itext, or PDFbox.
Usually one would use a library for that because PDF has many features, e.g. each node (called stream there) can be pressed, independetly from other streams. From the top of my head I do not know any JS library that would be able to produce valid PDF/A output. Allegedly (Nodejs library for creating/converting PDF/A) PDFme can do that.
Then you
- have a valid PDF/A document (incl. color profile etc.). You can validate e.g. using veraPDF. Please note that it is usually not possible to just filter out some things from ordinary PDF, PDF/A usually need to be constructed that way from ground up
- if not already PDF/A-3: label it like this (as it is backwards patible it's technically valid to upgrade e.g. a PDF/A-1 file to A/3 by just declaring it)
- add the embedded XML file
- add the PDF/A metadata extension to describe the embedded file (mandatory in PDF/A-3)
- add the RDF metadata required for factur-x
- validate the output again using verapdf and schema and schematron checks (or just use the mustangproject validation, which does all this)
hope that helps. Please let me know if it actually works with PDFme (or any other lib).
kind regards Jochen
本文标签: javascriptCreating invoice pdf within ZUGFeRD xml embeded on MERN projectStack Overflow
版权声明:本文标题:javascript - Creating invoice pdf within ZUGFeRD xml embeded on MERN project - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745585960a2664908.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论