Skip to content

Instantly share code, notes, and snippets.

@bjoerntx
Created June 5, 2023 09:49
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/a2288124fc0ddf1470e13701345d1e70 to your computer and use it in GitHub Desktop.
Save bjoerntx/a2288124fc0ddf1470e13701345d1e70 to your computer and use it in GitHub Desktop.
public byte[] CreateEncryptedPDF(byte[] document, X509Certificate2 certificate) {
byte[] bPDF;
using (TXTextControl.ServerTextControl tx = new TXTextControl.ServerTextControl()) {
tx.Create();
tx.Load(document, TXTextControl.BinaryStreamType.InternalUnicodeFormat);
// apply the first selected certificate
TXTextControl.SaveSettings saveSettings = new TXTextControl.SaveSettings() {
DigitalSignature = new TXTextControl.DigitalSignature(certificate, null)
};
// save the document as PDF
tx.Save(out bPDF, TXTextControl.BinaryStreamType.AdobePDFA, saveSettings);
}
return bPDF;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment