Last active
March 14, 2021 06:24
-
-
Save GroupDocsGists/ce12fd1c7f9f4c857413b1001586079d to your computer and use it in GitHub Desktop.
Sign Document with Digital Signatures in C#
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
// Sign PDF with digital certificate in C# | |
using (Signature signature = new Signature("document.pdf")) | |
{ | |
DigitalSignOptions options = new DigitalSignOptions("certificate.pfx"); | |
{ | |
ImageFilePath = "sampleImage.jpg", // Optional - Set image file path | |
Left = 50, // Set signature position | |
Top = 50, | |
Password = "GroupDocs" // Set Password | |
}; | |
signature.Sign("signedDocument.pdf", options); | |
} |
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
// Sign PDF with digital certificate in C# with custom appearance and setting | |
using (Signature signature = new Signature("document.pdf")) | |
{ | |
DigitalSignOptions options = new DigitalSignOptions("certificate.pfx") | |
{ | |
Password = "GroupDocs", | |
// digital certificate details | |
Reason = "Approved", | |
Location = "New York", | |
// Custom PDF signature appearance | |
Appearance = new PdfDigitalSignatureAppearance() | |
{ | |
// Do not show contact details | |
ContactInfoLabel = string.Empty, | |
// Simplify Reason Label | |
ReasonLabel = "?", | |
// Change Location Label | |
LocationLabel = "From", | |
DigitalSignedLabel = "By", | |
DateSignedAtLabel = "On", | |
Background = Color.Red | |
}, | |
AllPages = true, | |
Width = 160, | |
Height = 80, | |
// Set signature border | |
Border = new Border() | |
{ | |
Visible = true, | |
Color = Color.Red, | |
DashStyle = DashStyle.DashDot, | |
Weight = 2 | |
} | |
}; | |
SignResult signResult = signature.Sign("signedDocument.pdf", options); | |
} |
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
// Sign Word document with digital certificate in C# | |
using (Signature signature = new Signature("document.docx")) | |
{ | |
DigitalSignOptions options = new DigitalSignOptions("certificate.pfx"); | |
{ | |
ImageFilePath = "sampleImage.jpg", // Optional - Set image file path | |
Left = 50, // Set signature position | |
Top = 50, | |
Password = "GroupDocs" // Set Password | |
}; | |
signature.Sign("signedDocument.docx", options); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment