Skip to content

Instantly share code, notes, and snippets.

@bjoerntx
Last active November 10, 2020 10:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bjoerntx/e2f5e9f58dfe8ba749676ae110a6d473 to your computer and use it in GitHub Desktop.
Save bjoerntx/e2f5e9f58dfe8ba749676ae110a6d473 to your computer and use it in GitHub Desktop.
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