Skip to content

Instantly share code, notes, and snippets.

@bjoerntx
Created June 24, 2021 14:08
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/3e0ff0ddd7f719174e98a78f53f2b38c to your computer and use it in GitHub Desktop.
Save bjoerntx/3e0ff0ddd7f719174e98a78f53f2b38c to your computer and use it in GitHub Desktop.
public static SmartDocument ExtractSmartDocument(string DocumentName) {
SmartDocument smartDocument = new SmartDocument();
using (TXTextControl.ServerTextControl tx = new TXTextControl.ServerTextControl()) {
tx.Create();
// the load PDF document
TXTextControl.LoadSettings loadSettings = new LoadSettings();
tx.Load("App_Data/" + DocumentName,
TXTextControl.StreamType.AdobePDF,
loadSettings);
// loop through all attachments to find the original document
// and the annotations
foreach (EmbeddedFile file in loadSettings.EmbeddedFiles) {
if (file.FileName == "original.tx")
smartDocument.Document = Convert.ToBase64String((byte[])file.Data);
if (file.FileName == "annotations.json")
smartDocument.Annotations = System.Text.Encoding.UTF8.GetString((byte[])file.Data);
}
smartDocument.Name = DocumentName;
}
return smartDocument;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment