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.

Fri Oct 24, 2014 9:26 am

I try to merge several pdf files to pdf/a, which works fine for the most part. However, when 1 or more documents contains signatures, the merging is not succesfull and only the signed document is shows in Acrobat. I understand that the signature is not valid anymore after merging, but why is the output document incomplete? When I remove the sugnature widgetfields, merging is succesfull, however.

Code: Select all
private void Test()        {

            PdfDocument doc2 = new PdfDocument(@"C:\test\cds-certified-pdf-non-cds-compatible-certificate.pdf");
            PdfDocument doc3 = new PdfDocument(@"C:\test\E-iceblue Technology.pdf");

            //StripSignatures(doc2);
            //StripSignatures(doc3);

            //Create a pdf document.
            PdfDocument doc = new PdfDocument(PdfConformanceLevel.Pdf_A1B);

            doc.InsertPageRange(doc2, 0, doc2.Pages.Count - 1);
            doc.InsertPageRange(doc3, 0, doc3.Pages.Count - 1);

            doc.SaveToFile(@"C:\test\TestOut.pdf", FileFormat.PDF);

            doc.Close();
         
            doc2.Close();
            doc3.Close();

        }

        private void StripSignatures(PdfDocument doc)
        {

            var form = doc.Form as PdfFormWidget;
            if (form == null)
            {
                return;
            }

            var toDelete =  form.FieldsWidget.OfType<PdfSignatureFieldWidget>().ToList();

            toDelete.ForEach(fw => form.FieldsWidget.Remove(fw));                       
        }

sikke.kooistra@avanade.com
 
Posts: 33
Joined: Fri Jun 27, 2014 1:39 pm

Mon Oct 27, 2014 1:49 am

Dear sikke,

Thanks for your inquiry.

I tested merging signed pdf with code below and it worked well, please try it:
Code: Select all
string[] files= new string[]{"problem.pdf","DigitalSignature.pdf"};
PdfDocumentBase doc = PdfDocument.MergeFiles(files);
doc.Conformance = PdfConformanceLevel.Pdf_A1B;
doc.Save("Result.pdf", FileFormat.PDF);

Best Regards,
Burning
E-iceblue Support Team
Best Regards,
Burning
E-iceblue Support Team
User avatar

burning.liu
 
Posts: 406
Joined: Mon Aug 04, 2014 6:47 am

Wed Oct 29, 2014 7:01 am

Dear sikke,

Have you tried the code I sent you to resolve the problem?
Please feel free to contact us if you have any problems.

Best Regards,
Burning
E-iceblue Support Team
Best Regards,
Burning
E-iceblue Support Team
User avatar

burning.liu
 
Posts: 406
Joined: Mon Aug 04, 2014 6:47 am

Wed Oct 29, 2014 7:43 am

Hi,

I tried your code, the result is the same: Adobe Acrobat XI only shows 1 page (the signed pdf). I posted the source and resultfiles on https://onedrive.live.com/redir?resid=D ... =folder%2c (cannot upload to forum, the files are too big...)

sikke.kooistra@avanade.com
 
Posts: 33
Joined: Fri Jun 27, 2014 1:39 pm

Wed Oct 29, 2014 8:38 am

Dear sikke,

Thanks for your reply.
I have reproduced this issue which has been posted to our dev team, we will inform you there is any update.

Best Regards,
Burning
E-iceblue Support Team
Best Regards,
Burning
E-iceblue Support Team
User avatar

burning.liu
 
Posts: 406
Joined: Mon Aug 04, 2014 6:47 am

Wed Nov 12, 2014 8:51 am

Dear sikke,

We just released a new version of Spire.PDF (Spire.PDF Pack Version:3.2.0) to fix the issue "Merge signed or certified PDF's failes", you can download it via link below:
http://www.e-iceblue.com/downloads/spire.pdf_3.2.0.zip

Best Regards,
Burning
E-iceblue Support Team
Best Regards,
Burning
E-iceblue Support Team
User avatar

burning.liu
 
Posts: 406
Joined: Mon Aug 04, 2014 6:47 am

Wed Nov 19, 2014 9:26 am

I downloaded the new package, merging is fine now. I do notice, however, that you remove the signature fields when merging signed documents. Is that by design?

sikke.kooistra@avanade.com
 
Posts: 33
Joined: Fri Jun 27, 2014 1:39 pm

Wed Nov 19, 2014 10:09 am

Dear sikke,

I noticed that the signature fields missing in the generated document, we will do some investigation and let you know tomorrow.

Best Regards,
Burning
E-iceblue Support Team
Best Regards,
Burning
E-iceblue Support Team
User avatar

burning.liu
 
Posts: 406
Joined: Mon Aug 04, 2014 6:47 am

Thu Nov 20, 2014 2:35 am

Dear sikke,

As we all know that digitally signed PDF file is not able to be changed.If it is changed, it cannot be successfully decrypted.
After merging it with other document, its content is changed,hence the original signature would be removed automaticly.
Spire.PDF supports signing PDF document with digital certificate, you can refer to the code below:
Code: Select all
PdfDocument doc=new PdfDocument();
doc.LoadFromFile("Grid.pdf", FileFormat.PDF);
string pfxPath = "Demo.pfx";
PdfCertificate cert = new PdfCertificate(pfxPath, "e-iceblue");
PdfSignature signature = new PdfSignature(doc, doc.Pages[0], cert, "demo");
signature.ContactInfo = "Harry Hu";
signature.Certificated = true;
signature.DocumentPermissions = PdfCertificationFlags.AllowFormFill;
doc.SaveToFile("DigitalSignature.pdf", FileFormat.PDF);

Best Regards,
Burning
E-iceblue Support Team
Best Regards,
Burning
E-iceblue Support Team
User avatar

burning.liu
 
Posts: 406
Joined: Mon Aug 04, 2014 6:47 am

Tue Nov 25, 2014 9:22 am

Hi Burning,

The issue is that I'm not the one who signed the orignal documents, they come from other people. What I would expect after merging signed documents is the original signature still be in place, and a warning in Adobe that the signature(s) is/are invalid. This would have the following benefits:
- I still can see who signed the original documents
- I can see the documents have been edited after signing

However, this is not a big issue, if removing the signatures before merging is the only option for you, than this is OK.

Regards,

Sikke

sikke.kooistra@avanade.com
 
Posts: 33
Joined: Fri Jun 27, 2014 1:39 pm

Tue Nov 25, 2014 9:38 am

Dear sikke,

Please feel free to contact us if you have any problems.

Best Regards,
Burning
E-iceblue Support Team
Best Regards,
Burning
E-iceblue Support Team
User avatar

burning.liu
 
Posts: 406
Joined: Mon Aug 04, 2014 6:47 am

Return to Spire.PDF

cron