Created
June 10, 2023 20:53
-
-
Save bjoerntx/645c7c083f64956f5ad4348133f6be27 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 string UpdateDocument(string DocumentName, byte[] document) { | |
using (TXTextControl.ServerTextControl tx = new TXTextControl.ServerTextControl()) { | |
tx.Create(); | |
// the load PDF document | |
TXTextControl.LoadSettings loadSettings = new LoadSettings(); | |
tx.Load(DocumentName, | |
TXTextControl.StreamType.AdobePDF, | |
loadSettings); | |
List<EmbeddedFile> embeddedFiles = loadSettings.EmbeddedFiles.ToList(); | |
// create an attachment | |
EmbeddedFile embeddedFile = new EmbeddedFile("original.tx", document, null); | |
embeddedFile.Relationship = "Source"; | |
embeddedFiles.Add(embeddedFile); | |
TXTextControl.SaveSettings saveSettings = new TXTextControl.SaveSettings() { | |
EmbeddedFiles = embeddedFiles.ToArray() | |
}; | |
tx.Load(document, BinaryStreamType.InternalUnicodeFormat); | |
// save a PDF with the attached Text Control document embedded | |
tx.Save(DocumentName, | |
TXTextControl.StreamType.AdobePDF, | |
saveSettings); | |
} | |
return DocumentName; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment