Digitally sign PDF files

C#PdfDigital Signature

C# Problem Overview


I have a digital certificate that identifies an user. I need to use it to Digitally sign pdf files.

Does anyone have an example that does not uses a third party component? I need to get this done but it would be nice to fully understand how things are done.

C# Examples please :)

C# Solutions


Solution 1 - C#

The open source iTextSharp library will allow you to do this. Here's a post explaining how to digitally sign a pdf file. If you don't want to use a third party library then you can implement it yourself but it could be a tough task -> you can start by reading the pdf specification (8.6MB)

Solution 2 - C#

Proper PDF signing is a very sophisticated task. There exist a number of files that don't conform to the PDF specification (broken xrefs etc) and your code must handle all of them. Then various Acrobat versions treat certain things in signed fields differently. So if you need to do the task (rather than study how it works) you should rely on third-party solution, such as our http://www.eldos.com/sbbdev/net-pdf.php">PDFBlackbox</a> components.

Solution 3 - C#

Digitally signing a PDF document without using a third-party component entails a great deal of work and is generally best avoided.

Components do all the hard work for you, so you don't have to. You should find there are some excellent free PDF components available that will suit your needs.

The following example written in C# shows how simple it is to digitally sign a PDF document using ABCpdf:

Doc theDoc = new Doc();
theDoc.Read(Server.MapPath("../Rez/Authorization.pdf"));
Signature theSig = (Signature)theDoc.Form["Signature"];
theSig.Location = "Washington";
theSig.Reason = "Schedule Agreed";
theSig.Sign(Server.MapPath("../Rez/JohnSmith.pfx"), "111111");
theDoc.Save(Server.MapPath("Signed.pdf"));

Source: ABCpdf documentation - Sign method

Solution 4 - C#

Lost my first answer. May want to give DocQ a try to [link text][1] They have their own cert and can do this for you for free/cheap to seal and encrypt PDFs. They also have an API you can use.

[1]: https://docq.com/ "digitally sign a PDF"

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionSergioView Question on Stackoverflow
Solution 1 - C#Darin DimitrovView Answer on Stackoverflow
Solution 2 - C#Eugene Mayevski 'CallbackView Answer on Stackoverflow
Solution 3 - C#AffineMeshView Answer on Stackoverflow
Solution 4 - C#user337658View Answer on Stackoverflow