Skip to content

Instantly share code, notes, and snippets.

@bjoerntx
Created February 25, 2022 20:24
Show Gist options
  • Save bjoerntx/2cb8f2b1b92d1b5a13908a43522b3bdc to your computer and use it in GitHub Desktop.
Save bjoerntx/2cb8f2b1b92d1b5a13908a43522b3bdc to your computer and use it in GitHub Desktop.
// create a non-UI ServerTextControl instance
using (TXTextControl.ServerTextControl tx = new TXTextControl.ServerTextControl()) {
tx.Create();
// load the PDF document
TXTextControl.LoadSettings ls = new TXTextControl.LoadSettings();
tx.Load("document.pdf", TXTextControl.StreamType.AdobePDF, ls);
// read the attachments
TXTextControl.EmbeddedFile[] files = ls.EmbeddedFiles;
// find the specific attachment and save it
foreach(TXTextControl.EmbeddedFile file in files) {
if (file.Description == "My Text File") {
string sAttachment = Encoding.UTF8.GetString((byte[])file.Data);
System.IO.File.WriteAllText("attachment_read.txt", sAttachment);
break;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment