Created
June 24, 2021 14:08
-
-
Save bjoerntx/3e0ff0ddd7f719174e98a78f53f2b38c 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
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