Skip to content

Instantly share code, notes, and snippets.

@bjoerntx
Created June 10, 2023 20:53
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/645c7c083f64956f5ad4348133f6be27 to your computer and use it in GitHub Desktop.
Save bjoerntx/645c7c083f64956f5ad4348133f6be27 to your computer and use it in GitHub Desktop.
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