Created
February 25, 2022 20:02
-
-
Save bjoerntx/645a67afb83c130f1923dbf420ecd9fe 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
// 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