Skip to content

Instantly share code, notes, and snippets.

@bjoerntx
Created July 7, 2023 08:12
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/617c186328386f0e97b87e352144579a to your computer and use it in GitHub Desktop.
Save bjoerntx/617c186328386f0e97b87e352144579a to your computer and use it in GitHub Desktop.
using System.Text;
using (TXTextControl.ServerTextControl tx = new TXTextControl.ServerTextControl()) {
tx.Create();
tx.Text = "This is a sample PDF document with an attachment";
byte[] baAttachment = Encoding.ASCII.GetBytes("This is a textual attachment.");
// create a new embedded file
TXTextControl.EmbeddedFile efAttachment =
new TXTextControl.EmbeddedFile("attachment.tx", baAttachment, null) {
Description = "My embedded text file."
};
// add the embedded file to TextControl
tx.DocumentSettings.EmbeddedFiles =
new TXTextControl.EmbeddedFile[] { efAttachment };
// save the document
tx.Save("mypdf.pdf", TXTextControl.StreamType.AdobePDF);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment