Skip to content

Instantly share code, notes, and snippets.

@bjoerntx
Last active June 24, 2021 14:01
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/c84bc4027904bccd93d1bae6ca761eba to your computer and use it in GitHub Desktop.
Save bjoerntx/c84bc4027904bccd93d1bae6ca761eba to your computer and use it in GitHub Desktop.
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