ArtifexSoftware / Ghostscript.NET

Ghostscript.NET - managed wrapper around the Ghostscript library (32-bit & 64-bit). Tested with Ghostscript versions < 10.
https://ghostscript.com
GNU Affero General Public License v3.0
403 stars 155 forks source link

Support Factur-X #122

Open jstaerk opened 7 months ago

jstaerk commented 7 months ago

Factur-X is based on the idea to embed XML representations of invoices in PDF/A-3 files. Cross Industry Invoice CII XML is used for this purpose in it's 1.00 version, aka 2016b, i.e. compliant with the European B2G e-invoicing standard EN16931.

Factur-X is one of the three eligible formats for french invoices (apart from that you can use pure CII, or UBL).

~5years ago Ken Sharp laid the foundation allowing to write ZUGFeRD 1, ZUGFeRD 2, Factur-X, Order-X and the upcoming Deliver-X (see https://bugs.ghostscript.com/show_bug.cgi?id=696472) using Ghostscript. Currently no open source library is available for .net, konik only supports ZUGFeRD 1.0 (Factur-X 1.0=ZUGFeRD 2.0) and ZUGFeRD-csharp does not cover reading or writing to/from PDF at all.

jstaerk commented 7 months ago

Im working on merging my separately developed library in this branch, any help is greatly appreciated, I'm e.g. struggeling with the update to .net 6.0 which seemed neccessary :-(

In the end hopefully this will work (again)

namespace Ghostscript.NET.Samples
{
    public class FacturXWriteSample : ISample
    {

        public void Start()
        {

            Invoice i = (new Invoice()).setDueDate(DateTime.Now).setIssueDate(DateTime.Now).setDeliveryDate(DateTime.Now).setSender((new TradeParty("Test company", "teststr", "55232", "teststadt", "DE")).addTaxID("DE4711").addVATID("DE0815").setContact(new Contact("Hans Test", "+49123456789", "test@example.org")).addBankDetails(new BankDetails("DE12500105170648489890", "COBADEFXXX"))).setRecipient(new TradeParty("Franz Müller", "teststr.12", "55232", "Entenhausen", "DE")).setReferenceNumber("991-01484-64").setNumber("123").
                    addItem(new Item(new Product("Testprodukt", "", "C62", new BigDecimal(19)), new BigDecimal("1.0"), new BigDecimal("1.0")));

            ZUGFeRD2PullProvider zf2p = new ZUGFeRD2PullProvider();
            zf2p.setProfile(Profiles.getByName("XRechnung"));
            zf2p.generateXML(i);
            System.Text.UTF8Encoding encoding = new System.Text.UTF8Encoding();

            string outfilename = "xrechnung.xml";
            File.WriteAllBytes(outfilename, zf2p.getXML());
        }

    }
}