Created
June 5, 2023 09:49
-
-
Save bjoerntx/a2288124fc0ddf1470e13701345d1e70 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
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