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 21, 2017 12:20 pm

Hello,

I want to store my pdf files with conformance level PDF-A and digital signature, is that possible in combination? Both functionalities for themself work perfect, but I do not get a result for both combined. I tried both ways: First set to PDF-A and then add a signature and first add a signature and then convert to PDF-A. Is there a thrird possibility or do I have made a mistake?

Thanks in advance
Daniel

DanielZ
 
Posts: 6
Joined: Mon Jan 04, 2016 9:52 am

Fri Dec 22, 2017 6:39 am

Hello Daniel,

Thanks for your post. First set to PDF-A and then add a signature is working on my side. Please use the latest version(Spire.PDF Pack(Hot Fix) Version:3.9.538) and refer to the bellow code snippet to have a try.
Code: Select all
            PdfDocument OriginalDoc = new PdfDocument();
            OriginalDoc.LoadFromFile(@"sample.pdf", Spire.Pdf.FileFormat.PDF);

            PdfNewDocument newDOC = new PdfNewDocument();
            newDOC.Conformance = PdfConformanceLevel.Pdf_A1A;
            foreach (PdfPageBase page in OriginalDoc.Pages)
            {
                SizeF size = page.Size;
                PdfPageBase p = newDOC.Pages.Add(size, new Spire.Pdf.Graphics.PdfMargins(0));
                page.CreateTemplate().Draw(p, 0, 0);
            }
           
            Sign(newDOC);

            newDOC.Save("result-a.pdf");
        private static void Sign(PdfDocumentBase doc)
        {
            String pfxPath = @"gary.pfx";
            PdfCertificate digi = new PdfCertificate(pfxPath, "e-iceblue");
            PdfSignature signature = new PdfSignature(doc, doc.Pages[0], digi, "demo");

            signature.Bounds = new RectangleF(new PointF(50, 10), new SizeF(260, 90));
            signature.DistinguishedName = "Simon";
            signature.DistinguishedNameLabel = "Signer:";
            signature.LocationInfoLabel = "Location:";
            signature.LocationInfo = "BARI";
            signature.ReasonLabel = "Reason: ";
            signature.Reason = "PRESA VISIONE2";
            signature.DateLabel = "Date: ";
            signature.Date = DateTime.Now;
            signature.ContactInfoLabel = "Contact: ";
            signature.ContactInfo = "123456789";
            signature.Certificated = true;
            signature.DocumentPermissions = PdfCertificationFlags.AllowFormFill;
        }


Best regards,
Simon
E-iceblue support team
User avatar

Simon.yang
 
Posts: 620
Joined: Wed Jan 11, 2017 2:03 am

Mon Dec 25, 2017 9:47 am

Hello Daniel,

Greeting from E-iceblue.
How is the issue going? Is the solution I provided working on your side?
Your feedback will be greatly appreciated.

Best regards,
Simon
E-iceblue support team
User avatar

Simon.yang
 
Posts: 620
Joined: Wed Jan 11, 2017 2:03 am

Tue Jan 02, 2018 5:36 am

Hello Simon,

thanks for your fast answer and the provided solution. I had holidays the last week and could not test it yet. I will answer when I tested your code snippet and will check if the latest Spire.PDf is installed.

Thanks.

Best regards
Daniel

DanielZ
 
Posts: 6
Joined: Mon Jan 04, 2016 9:52 am

Tue Jan 02, 2018 6:44 am

Simon.yang wrote:Hello Daniel,

Greeting from E-iceblue.
How is the issue going? Is the solution I provided working on your side?
Your feedback will be greatly appreciated.

Best regards,
Simon
E-iceblue support team


Hello Simon,

now I tested your solution and it works very well. Thanks for the help!

Best regards,
Daniel

DanielZ
 
Posts: 6
Joined: Mon Jan 04, 2016 9:52 am

Tue Jan 02, 2018 7:14 am

Hello Daniel,

Thanks for your feedback. If you encounter any other question, welcome to contact us.

Best regards,
Simon
E-iceblue support team
User avatar

Simon.yang
 
Posts: 620
Joined: Wed Jan 11, 2017 2:03 am

Return to Spire.PDF