Created
February 25, 2022 20:24
-
-
Save bjoerntx/2cb8f2b1b92d1b5a13908a43522b3bdc 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
// 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