Created
January 2, 2025 12:21
-
-
Save bjoerntx/4c57ffd78ce4cf242522dced9fdf1def to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Serialize the XRechnung object to JSON | |
| string json = JsonSerializer.Serialize(xRechnung); | |
| // Generate the ZUGFeRD XML | |
| string xmlZugferd = xRechnung.CreateXML(); | |
| // Load metadata from the XML file | |
| string metaData = File.ReadAllText("metadata.xml"); | |
| // Create an embedded file for the ZUGFeRD invoice | |
| var zugferdInvoice = new TXTextControl.EmbeddedFile( | |
| "factur-x.xml", | |
| Encoding.UTF8.GetBytes(xmlZugferd), | |
| metaData) | |
| { | |
| Description = "factur-x", | |
| Relationship = "Alternative", | |
| MIMEType = "application/xml", | |
| LastModificationDate = DateTime.Now | |
| }; | |
| // Configure save settings with the embedded file | |
| var saveSettings = new TXTextControl.SaveSettings | |
| { | |
| EmbeddedFiles = new[] { zugferdInvoice } | |
| }; | |
| // Create, modify, and save the PDF document | |
| using (var tx = new TXTextControl.ServerTextControl()) | |
| { | |
| tx.Create(); | |
| tx.Text = "Test Document"; | |
| tx.Save("test.pdf", TXTextControl.StreamType.AdobePDFA, saveSettings); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment