Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Thu Dec 05, 2013 3:43 pm

Hi,

How can I make visible the digital signature applied to an existing pdf file with the Spire.pdf product?

Thanks.

Best regards,

Galder

inyazar
 
Posts: 24
Joined: Wed Jul 03, 2013 8:38 am

Fri Dec 06, 2013 3:57 am

Dear Galder,

Thanks for your inquiry.
Please refer to the following code.
Code: Select all
 PdfDocument document = new PdfDocument();
            document.LoadFromFile(@"..\..\test.pdf");

            PdfCertificate certificate = new PdfCertificate("Demo.pfx", "e-iceblue");

            //Add signature
            var signature1 = new PdfSignature(document, document.Pages[0], certificate, "requested1");
            signature1.DocumentPermissions = PdfCertificationFlags.ForbidChanges;
            signature1.ContactInfo = "Harry Hu";
            signature1.Reason = "test1";
            signature1.LocationInfo = "home1";
            signature1.Certificated = true;
            document.CompressionLevel = PdfCompressionLevel.Best;

            document.SaveToFile("result.pdf", FileFormat.PDF);


Best regards,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2766
Joined: Wed Jun 27, 2012 8:50 am

Tue Dec 10, 2013 10:28 am

Hello Amy,

I try the code and still I don't see the digital signature in PDF file.

It exists but when I print it doesn't show. I want to print the digital signature in the PDF file so I can see it

Thanks.

Best regards,
Galder

inyazar
 
Posts: 24
Joined: Wed Jul 03, 2013 8:38 am

Wed Dec 11, 2013 4:04 am

Dear Galder,

Sorry that I misunderstand your question. I attached a sample PDF with digital signature. Would you please check it and tell us if it is what you desire? Thank you.
If it is, sorry that our Spire.PDF doesn't support the feature at present, but we have added it into our schedule.

Best regards,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2766
Joined: Wed Jun 27, 2012 8:50 am

Wed Dec 11, 2013 12:34 pm

Hello Amy,

This is that I wanted. Thanks.

Please tell me when the feature is working.

Best Regards,
Galder

inyazar
 
Posts: 24
Joined: Wed Jul 03, 2013 8:38 am

Thu Dec 12, 2013 1:22 am

Dear Galder,

Thanks for your reply.
We will inform you immediately as soon as the feature is supported.

Best regards and have a nice day,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2766
Joined: Wed Jun 27, 2012 8:50 am

Fri Dec 20, 2013 9:13 am

Dear Galder,

Thanks for your waiting.
The new feature has been supported. Sorry that we have not had a new version of Spire.Office at present. Please firstly test new hot fix of Spire.PDF, Spire.PDF Pack(Hot Fix) Version:2.9.7 (http://www.e-iceblue.com/Download/downl ... t-now.html). We will inform you when there is a new version of Spire.Office.
Attached sample code:
Code: Select all
PdfDocument doc = new PdfDocument("D:\\test.pdf");
            PdfCertificate cert = new PdfCertificate("D:\\Demo.pfx", "e-iceblue");
            var signature = new PdfSignature(doc, doc.Pages[0], cert, "Requestd1");
            signature.Bounds = new RectangleF(new PointF(280, 600), new SizeF(260, 90));
            signature.IsTag = true;

            signature.DigitalSignerLable= "Digitally signed by";
            signature.DigitalSigner = "Harry Hu for Tests";

            signature.DistinguishedName = "DN: ";
            signature.LocationInfoLabel = "Location: ";
            signature.LocationInfo = "London";

            signature.ReasonLabel = "Reason: ";
            signature.Reason = "Testing ";

            signature.DateLabel = "Date: ";
            signature.Date = DateTime.Now;

            signature.ContactInfoLabel = "Contact: ";
            signature.ContactInfo = "123456789";

            signature.Certificated = false;

            signature.ConfigGraphicType = ConfiguerGraphicType.Picture;
            signature.ConfiguerGraphicPath = "D:\\sign.png";

            signature.DocumentPermissions = PdfCertificationFlags.ForbidChanges;

            doc.SaveToFile("sample.pdf");


Best regards,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2766
Joined: Wed Jun 27, 2012 8:50 am

Tue Jan 21, 2014 6:40 am

Dear Galder,

Thanks for your waiting.
A new version of Spire.Office has been released.
Welcome to test Spire.Office Platinum 2.7(http://www.e-iceblue.com/Download/downl ... t-now.html).

Best wishes and have a nice day,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2766
Joined: Wed Jun 27, 2012 8:50 am

Thu Jan 19, 2023 1:59 pm

Thank you all for your answers.
It was really helpful.
Can someone explain to me what is the use of "signature.Certificated = true" ?
Because in the same question, two different values are assigned to it. So I am totally confused with it.

fipldevops
 
Posts: 6
Joined: Thu Jan 19, 2023 1:52 pm

Fri Jan 20, 2023 2:29 am

Hello,

Thanks for your inquiry.
The secret key of certificate is added to the result pdf document when you set signature.Certificated to true, if you set signature.Certificated to false, the secret key of certificate is not added to the result pdf document.

Sincerely
Abel
E-iceblue support team
User avatar

Abel.He
 
Posts: 860
Joined: Tue Mar 08, 2022 2:02 am

Mon Jan 23, 2023 5:40 am

What is the secret key of the certificate?
Is it different from the private key and public key of the certificate?

fipldevops
 
Posts: 6
Joined: Thu Jan 19, 2023 1:52 pm

Mon Jan 23, 2023 9:33 am

Hello,

Thank you for your feedback.
We are now having our Spring Festival holiday from 21/01/2023 to 27/01/2023 (GMT+8:00). The key of the certificate is the password when we use the certificate to sign, but I'm not sure whether this property setting is private key or public key. When we return to work after the holiday, we will further confirm with our R&D colleagues and inform you.

Sincerely,
Annika
E-iceblue support team
User avatar

Annika.Zhou
 
Posts: 1643
Joined: Wed Apr 07, 2021 2:50 am

Sat Jan 28, 2023 10:28 am

Hello fipldevops,

Thank you for your patience.
I'm sorry that the colleague who handled your problem explained the use of "signature.Certified=true" incorrectly. After detailed communication with the development team, I am sure that "signature.Certified=true" is used to ensure that the entire document has and only has one signature, which has been verified. Using "signature.Certified=false", the PDF document can have multiple signatures and all signatures are valid, but these signatures have not been verified.
In addition, using "signature.Certified=true" has nothing to do with the private key or public key of the signing certificate.
We apologize for the inconvenience caused again.

Sincerely,
Annika
E-iceblue support team
User avatar

Annika.Zhou
 
Posts: 1643
Joined: Wed Apr 07, 2021 2:50 am

Return to Spire.PDF