Last active
January 18, 2021 20:08
-
-
Save bjoerntx/b2d6e3d3e4afab81c71335ff5054b363 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 string GetXmlAttachment(string Filename) { | |
using (TXTextControl.ServerTextControl tx = new TXTextControl.ServerTextControl()) { | |
tx.Create(); | |
// load documment | |
LoadSettings ls = new TXTextControl.LoadSettings() { | |
PDFImportSettings = PDFImportSettings.LoadEmbeddedFiles | |
}; | |
tx.Load(Filename, TXTextControl.StreamType.AdobePDF, ls); | |
// all attachments | |
var embeddedFiles = ls.EmbeddedFiles; | |
// find the "alternative" xml representation | |
foreach (EmbeddedFile embeddedFile in embeddedFiles) { | |
if (embeddedFile.Relationship == "Alternative" && | |
embeddedFile.MIMEType == "text/xml") { | |
// return converted XML | |
return Encoding.UTF8.GetString((byte[])embeddedFile.Data); | |
} | |
} | |
return null; //something went wrong | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment