Last active
June 24, 2021 14:01
-
-
Save bjoerntx/c84bc4027904bccd93d1bae6ca761eba to your computer and use it in GitHub Desktop.
This file contains hidden or 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 string CreateNewDocument() { | |
var DocumentName = Guid.NewGuid().ToString() + ".pdf"; | |
using (TXTextControl.ServerTextControl tx = new TXTextControl.ServerTextControl()) { | |
tx.Create(); | |
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("App_Data/" + 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