Created
June 10, 2023 20:35
-
-
Save bjoerntx/d8c088eb2efaef65cea1f7c41fd6a95f 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 CreateNewDocument(byte[] document) { | |
var DocumentName = Guid.NewGuid().ToString() + ".pdf"; | |
using (TXTextControl.ServerTextControl tx = new TXTextControl.ServerTextControl()) { | |
tx.Create(); | |
tx.Load(document, BinaryStreamType.InternalUnicodeFormat); | |
byte[] dataTx; | |
// save the blank document in the internal TX format | |
tx.Save(out dataTx, TXTextControl.BinaryStreamType.InternalUnicodeFormat); | |
// create an attachment | |
EmbeddedFile embeddedFile = new EmbeddedFile("original.tx", dataTx, null); | |
embeddedFile.Relationship = "Source"; | |
TXTextControl.SaveSettings saveSettings = new TXTextControl.SaveSettings() { | |
EmbeddedFiles = new EmbeddedFile[] { embeddedFile } | |
}; | |
// 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