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.

Tue Jul 14, 2015 7:39 am

Hi there!
When I use Spire.PDF trial version, I have two issues, the first digital signature will be invalid when I add a second one and they aren't visible on PDF. I consider the license version can fix those issues, right?

Image

This is my codes:
Code: Select all
            PdfDocument doc = new PdfDocument();
            doc.LoadFromFile(@"../../DOTForm.pdf");           
            PdfPageBase page = doc.Pages[0];
            String pfxPath = @"../../HungBui.pfx";
            PdfCertificate cert = new PdfCertificate(pfxPath, "abcxyz");
            var form = (PdfFormWidget)doc.Form;
            if (form.FieldsWidget.Count > 0)
            {
                var field = form.FieldsWidget["Signature"] as PdfSignatureFieldWidget;
                PdfSignature signature = new PdfSignature(doc, page, cert, "demo", field);
                signature.DocumentPermissions = PdfCertificationFlags.ForbidChanges;
                signature.IsTag = true;
                signature.DigitalSignerLable = "Digitally signed by";
                signature.DigitalSigner = "Hung Bui";
                signature.DistinguishedName = "DN:";
                signature.LocationInfoLabel = "Location:";
                signature.LocationInfo = "London";
                signature.ReasonLabel = "Reason: ";
                signature.Reason = "Le document est certifie";
                signature.DateLabel = "Date: ";
                signature.Date = DateTime.Now;
                signature.ContactInfoLabel = "Contact: ";
                signature.ContactInfo = "123456789";
                signature.Certificated = true;               
            }
            //Save pdf file.
            doc.CompressionLevel = PdfCompressionLevel.Best;
            doc.SaveToFile(@"../../DigitalSignature.pdf");
            doc.Close();

khanhhung271
 
Posts: 3
Joined: Mon Jul 13, 2015 10:54 am

Tue Jul 14, 2015 8:34 am

Hello,

Thanks for your inquiry.
Could you please offer us your sample files( DOTForm.pdf and HungBui.pfx)?
Please kindly note that firstly you need to compress it and upload.
Or you can send it to us ( Support@e-iceblue.com ) via email.
It would be helpful to replicate the issue and work out the solution for you ASAP.

Best Regards,
Sweety

E-iceblue support team
User avatar

sweety1
 
Posts: 539
Joined: Wed Mar 11, 2015 1:14 am

Tue Jul 14, 2015 9:11 am

I sent the sample files to you via email, I used Demo.pfx instead of my pfx file for security.
Thanks for your help!

khanhhung271
 
Posts: 3
Joined: Mon Jul 13, 2015 10:54 am

Wed Jul 15, 2015 1:41 am

Hello,

Thanks for your information.
Sorry that I didn't find your email.
Please check it.

Best Regards,
Sweety

E-iceblue support team
User avatar

sweety1
 
Posts: 539
Joined: Wed Mar 11, 2015 1:14 am

Wed Jul 15, 2015 3:18 am

Hello sweety1,

I checked my email and I see it sent failed because mail server looked it like virus. So I uploaded the sample files to dropbox, you can download them from link below:

dropbox .com /s/6t2nev7bmve8kiv/DigitalSignature.zip?dl=0

Please remove spaces, I don't have permission to post URL.
Thanks buddy!

khanhhung271
 
Posts: 3
Joined: Mon Jul 13, 2015 10:54 am

Wed Jul 15, 2015 9:08 am

Hello,

Thanks for your information.
I have noticed your issues. And I have posted the issues to our dev team. We will inform you when they are fixed. Sorry for the inconvenience.

Best Regards,
Sweety

E-iceblue support team
User avatar

sweety1
 
Posts: 539
Joined: Wed Mar 11, 2015 1:14 am

Wed Sep 28, 2016 6:27 am

Dear khanhhung271,

Thanks for your waiting.
Now the multiple signature issue has been resolved, welcome to test Spire.PDF Pack(Hot Fix) Version:3.7.330.
Please note that you need to save the pdf after a signature, and then load the pdf and sign the document again.
Here is sample code for your reference.
Code: Select all
                PdfDocument doc = new PdfDocument();
                doc.LoadFromFile(@"../../DOTForm.pdf");
                PdfPageBase page = doc.Pages[0];
                String pfxPath = @"../../Demo.pfx";
                PdfCertificate cert = new PdfCertificate(pfxPath, "e-iceblue");

                var form = (PdfFormWidget)doc.Form;
                var field = form.FieldsWidget["Signature"] as PdfSignatureFieldWidget;

                PdfSignature signature = new PdfSignature(doc, page, cert, "demo", field);
                signature.IsTag = true;
                signature.DigitalSignerLable = "Digitally signed by";
                signature.DigitalSigner = "Harry Hu";
                signature.DistinguishedName = "DN:";
                signature.LocationInfoLabel = "Location:";
                signature.LocationInfo = "London";
                signature.ReasonLabel = "Reason: ";
                signature.Reason = "Le document est certifie";
                signature.DateLabel = "Date: ";
                signature.Date = DateTime.Now;
                signature.ContactInfoLabel = "Contact: ";
                signature.ContactInfo = "123456789";
                signature.DocumentPermissions = PdfCertificationFlags.AllowFormFill;

                //save the pdf and then load it and sign again
                MemoryStream ms = new MemoryStream();
                doc.SaveToStream(ms);
                doc.LoadFromStream(ms);
                page = doc.Pages[0];
                form = (PdfFormWidget)doc.Form;
                var field1 = form.FieldsWidget["Drivers Signature"] as PdfSignatureFieldWidget;
                signature = new PdfSignature(doc, page, cert, "demo", field);
                signature.IsTag = true;
                signature.DigitalSignerLable = "Digitally signed by";
                signature.DigitalSigner = "Harry Hu";
                signature.DistinguishedName = "DN:";
                signature.LocationInfoLabel = "Location:";
                signature.LocationInfo = "London";
                signature.ReasonLabel = "Reason: ";
                signature.Reason = "Le document est certifie";
                signature.DateLabel = "Date: ";
                signature.Date = DateTime.Now;
                signature.ContactInfoLabel = "Contact: ";
                signature.ContactInfo = "123456789";
                signature.DocumentPermissions = PdfCertificationFlags.AllowFormFill;
                doc.SaveToFile(@"DigitalSignature.pdf");
                doc.Close();

If there is any question, welcome to get it back to us.

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Fri Apr 22, 2022 8:10 am

Hello,

Thanks for your patience.
Glad to inform you that we just released Spire.PDF Pack(Hot Fix) Version:8.4.15, which fixes the multi-signature issue. please download and refer to the sample code for testing.

Website link: https://www.e-iceblue.com/Download/download-pdf-for-net-now.html
NuGet link: https://www.nuget.org/packages/Spire.PDF/8.4.15
Code: Select all
X509Certificate2 x509 = new X509Certificate2(pfxPath, "e-iceblue");
PdfDocument doc = new PdfDocument();
doc.LoadFromFile(inputFile);
PdfOrdinarySignatureMaker signatureMaker = new PdfOrdinarySignatureMaker(doc, x509);
IPdfSignatureAppearance signatureAppearance = new PdfCustomSignatureAppearanc();
signatureMaker.MakeSignature("Signature", signatureAppearance);
signatureMaker.MakeSignature("Driver’s Signature", signatureAppearance);
doc.SaveToFile(outputFile, FileFormat.PDF);
doc.Close();

public class PdfCustomSignatureAppearanc : IPdfSignatureAppearance
{
    public void Generate(PdfCanvas g)
       {
           float x = 2;
           float y = 2;
           float fontSize = 10;
           PdfTrueTypeFont font = new PdfTrueTypeFont(new Font("Arial", fontSize), false);
           float lineHeight = fontSize;
           g.DrawString("AAAAAAAAAAA", font, PdfBrushes.Red, new PointF(0, 0));
       }
}

Sincerely,
Annika
E-iceblue support team
User avatar

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

Return to Spire.PDF