Skip to content

Instantly share code, notes, and snippets.

@bjoerntx
Created February 25, 2022 20:02
Show Gist options
  • Save bjoerntx/645a67afb83c130f1923dbf420ecd9fe to your computer and use it in GitHub Desktop.
Save bjoerntx/645a67afb83c130f1923dbf420ecd9fe to your computer and use it in GitHub Desktop.
// create a non-UI ServerTextControl instance
using (TXTextControl.ServerTextControl tx = new TXTextControl.ServerTextControl()) {
tx.Create();
// set dummy content
tx.Text = "PDF Document Content";
// read the content of the attachment
string sAttachment = System.IO.File.ReadAllText("attachment.txt");
// create the attachement
TXTextControl.EmbeddedFile attachment =
new TXTextControl.EmbeddedFile(
"attachment.txt",
sAttachment,
null) {
Description = "My Text File",
Relationship = "Unspecified",
MIMEType = "application/txt",
CreationDate = DateTime.Now,
};
// attached the embedded file
tx.DocumentSettings.EmbeddedFiles =
new TXTextControl.EmbeddedFile[] { attachment };
// save as PDF/A
tx.Save("document.pdf", TXTextControl.StreamType.AdobePDFA);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment