Digitally sign PDF files

87,473

Solution 1

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

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 PDFBlackbox components.

Solution 3

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

Lost my first answer. May want to give DocQ a try to link text 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.

Share:
87,473
Sergio
Author by

Sergio

I'm a curious web programmer that works with c# web applications.

Updated on July 08, 2022

Comments

  • Sergio
    Sergio almost 2 years

    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 :)