Created
September 15, 2022 18:38
-
-
Save bjoerntx/b82b3ea942058be7aa590127bbcc43a8 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 static void SignFields() { | |
using (ServerTextControl tx = new ServerTextControl()) { | |
tx.Create(); | |
// create a signature field | |
SignatureField signatureField = new SignatureField( | |
new System.Drawing.Size(2000, 2000), "txsign", 10); | |
// set image representation | |
signatureField.Image = new SignatureImage("signature.svg", 0); | |
// insert the field | |
tx.SignatureFields.Add(signatureField, -1); | |
// create a digital signature (for each field, if required) | |
DigitalSignature digitalSignature = new DigitalSignature( | |
new System.Security.Cryptography.X509Certificates.X509Certificate2( | |
"textcontrolself.pfx", "123"), null, "txsign"); | |
// apply the signatures to the SaveSettings | |
SaveSettings saveSettings = new SaveSettings() { | |
SignatureFields = new DigitalSignature[] { digitalSignature } | |
}; | |
// export to PDF | |
tx.Save("signed_fields.pdf", StreamType.AdobePDF, saveSettings); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment