Last active
November 10, 2020 10:12
-
-
Save bjoerntx/e2f5e9f58dfe8ba749676ae110a6d473 to your computer and use it in GitHub Desktop.
This file contains 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
private InvoiceDescriptor ImportZUGFeRD(string filename) { | |
// temporary ServerTextControl to load PDF | |
using (TXTextControl.ServerTextControl tx = new TXTextControl.ServerTextControl()) { | |
tx.Create(); | |
TXTextControl.LoadSettings ls = new TXTextControl.LoadSettings() { | |
PDFImportSettings = TXTextControl.PDFImportSettings.LoadEmbeddedFiles | |
}; | |
// load the embedded file into LoadSettings | |
tx.Load(filename, TXTextControl.StreamType.AdobePDF, ls); | |
// convert the byte[] to a MemoryStream | |
byte[] byteArray = (byte[])ls.EmbeddedFiles[0].Data; | |
MemoryStream stream = new MemoryStream(byteArray); | |
// return the invoice object structure | |
return InvoiceDescriptor.Load(stream); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment