PdfSharpCore
PdfSharpCore copied to clipboard
is digital signature supported?
I can't find the source code here to do so...
There are two unresolved pull request in the predecessor project PDFsharp:
- https://github.com/empira/PDFsharp/pull/11/files (Support of Digital Signatures and Attachment Annotations)
- https://github.com/empira/PDFsharp/pull/10/files (Support of digital signatures)
Stack overflow:
- https://stackoverflow.com/questions/57654662/add-field-for-a-digital-signature-to-pdf
I might be willing to port the digital signature part if there is interest and a chance to merge it.
If it wasn't in PdfSharp, then it's not in PdfSharp-Core. Sure, I'll merge it, if you create a pull request. Just make sure there are no merge conflict (aka pull from the latest version before you begin working).
When i look at the digital signature support in the pull request i am not so happy. Its not generic enough.
This would generate an invisible signature.:
// load certificate
PdfCertificate cert = new PdfCertificate("C:\\Temp\\MyCertificate.pfx", "password of cert");
// create signature object
PdfSignature signature = new PdfSignature(doc, doc.Pages[doc.Pages.Count - 1], cert, "name of signature");
And we can extend it to support visible signatures too like:
var rect = new PdfRectangle(new XPoint(480, 33.75), new XPoint(612.2, 62.1));
signature.Bounds = rect;
...
// set signature content
signature.NameLabel = "Signer:";
signature.Name = "Bob";
signature.ContactInfoLabel = "Phone:";
signature.ContactInfo = "0123456";
signature.DateLabel = "Date:";
signature.Date = DateTime.Now;
signature.LocationInfoLabel = "Location:";
signature.LocationInfo = "Switzerland";
signature.ReasonLabel = "Reason:";
signature.Reason = "I am the author";
signature.DistinguishedNameLabel = "DN:";
signature.DistinguishedName = signature.Certificate.IssuerName.Name;
...
FYI this pull requests 10 and 11 have been ported to the new PDFsharp 6 in https://github.com/empira/PDFsharp/pull/48
Also, we did a nuget package of PDFsharp 6 with additional features, including signature. Try it here https://www.nuget.org/packages/PDFsharp-extended/ Note that this new PDFsharp-extended package is netstandard2.0 compatible
FYI this pull requests 10 and 11 have been ported to the new PDFsharp 6 in empira/PDFsharp#48
Also, we did a nuget package of PDFsharp 6 with additional features, including signature. Try it here https://www.nuget.org/packages/PDFsharp-extended/ Note that this new PDFsharp-extended package is netstandard2.0 compatible
Is there any documentation where I can find a sample on how to sign documents?
Thanks.
FYI this pull requests 10 and 11 have been ported to the new PDFsharp 6 in empira/PDFsharp#48 Also, we did a nuget package of PDFsharp 6 with additional features, including signature. Try it here https://www.nuget.org/packages/PDFsharp-extended/ Note that this new PDFsharp-extended package is netstandard2.0 compatible
Is there any documentation where I can find a sample on how to sign documents?
Thanks.
Hi @HClausing There is no documentation yet. You can find a sample in the first comment here: https://github.com/empira/PDFsharp/pull/48 And another sample in this comment: https://github.com/empira/PDFsharp/pull/48#issuecomment-1787587879
Hey @julienrffr Seem to be running into an issue with PDFSharp-extended. I'm attempting to password protect and sign a PDF, the password I'm using doesn't work on the final document.
It does, however, work in PDFSharp 6.
Was unable to bring this up in your repo.
Please advise.