Sign a PDF file using multiple signatures

Hello Aspose Team,


I checked out this Article and I want to accomplish multiple signatures task. Unfortunately when I copy C# code snippet to Visual Studio it shows me that Pkcs1Signature and Pkcs7Signature types are not exists.

I also tried to accomplish this task using PKCS1 and PKCS7 types - no luck, the output file contains all signatures but only last is valid - same problem as in this thread.

I need your help to accomplish this task.

Hi there,


Thanks for your inquriy. Please note Pkcs1Signature and Pkcs7Signature objects are obsolete now you need to use PKCS1 and PKCS7 objects for the purpose. We will update the documentation page soon.

Furthermore, the above stated issue related to signing PDF Form with multiple signature is not resolved yet. We have linked you post to the issue id PDFNEWNET-38630 and will keep you updated about the issue resolution progress. However we will appreciate it if you please share your sample code and input/output documents here, so we will also double check whether your issue is same or different.

We are sorry for the inconvenience caused.

Best Regards,

I used sample code from this [Article](http://www.aspose.com/docs/display/pdfnet/Improved+and+Flexible+PDF+Signing+Mechanism), section with multiple signatures. And this [document](https://github.com/asposepdf/Aspose_Pdf_NET/blob/master/Examples/CSharp/AsposePDF/Security-Signatures/Data/DigitallySign.pdf)

//create FormEditor object
FormEditor editor = new FormEditor(“input.pdf”, “WithSignatureFields.pdf”);
//add signature fields
editor.AddField(FieldType.Signature, “Signature from Alice”, 1, 10, 10, 110, 110);
editor.AddField(FieldType.Signature, “Signature from John”, 1, 120, 150, 220, 250);
editor.AddField(FieldType.Signature, “Signature from Smith”, 1, 300, 200, 400, 300);
//save the form
editor.Save();

//add signature to any of the signature fields
PdfFileSignature pdfSign = new PdfFileSignature(“WithSignatureFields.pdf”, “SignedByJohn.pdf”);
pdfSign.Sign(“Signature from John”, “Signature Reason”, “John”, “Kharkov”, new Pkcs1Signature(“test.pfx”, “password”));
//each time new signature is added you must save the document
pdfSign.Save();

//add second signature
PdfFileSignature pdfSign2 = new PdfFileSignature(“SignedByJohn.pdf”,“SignedByJohnAndAlice.pdf”);
pdfSign2.Sign(“Signature from Alice”, “Signature Reason”, “Alice”, “Odessa”, new Pkcs7Signature(false, “test2.pfx”, “password”));
//each time new signature is added you must save the document
pdfSign2.Save();

Hi there,


Thanks for sharing additional information. I have tested the scenario with following code snippet using sample pfx files and Aspose.Pdf for .NET 11.4.0 but unable to notice the reported issue. Please try this with latest version of Aspose.Pdf for .NET and share the results.

//create FormEditor object<o:p></o:p>

FormEditor editor = new FormEditor();

editor.BindPdf(myDir+"Helloworld.pdf");

//add signature fields

editor.AddField(Aspose.Pdf.Facades.FieldType.Signature, "Signature from Alice", 1, 10, 10, 110, 110);

editor.AddField(Aspose.Pdf.Facades.FieldType.Signature, "Signature from John", 1, 120, 150, 220, 250);

editor.AddField(Aspose.Pdf.Facades.FieldType.Signature, "Signature from Smith", 1, 300, 200, 400, 300);

//save the form

editor.Save(myDir+"WithSignatureFields.pdf");

//add signature to any of the signature fields

PdfFileSignature pdfSign = new PdfFileSignature();

pdfSign.BindPdf(myDir+"WithSignatureFields.pdf");

pdfSign.Sign("Signature from John", "Signature Reason", "John", "Kharkov", new PKCS1(myDir+"temp.pfx", "password"));

//each time new signature is added you must save the document

pdfSign.Save(myDir+"SignedByJohn.pdf");

//add second signature

PdfFileSignature pdfSign2 = new PdfFileSignature();

pdfSign2.BindPdf(myDir+"SignedByJohn.pdf");

pdfSign2.Sign("Signature from Alice", "Signature Reason", "Alice", "Odessa", new PKCS7(myDir + "test.pfx", "password"));

//each time new signature is added you must save the document

pdfSign2.Save(myDir+"SignedByJohnAndAlice.pdf");


Best Regards,

Hello Tilal,


Thanks for the answer, it works fine, but not with all documents. Some documents says that only last signature is valid. Can you please test it with this sample documents(attached)

Hi there,


Thanks for your feedback. I have tested the multiple signature scenario with your above shared with Aspose.Pdf for .NET 11.4.0 and unable to notice any issue, please find attached screenshots for your reference.

Best Regards,
hi, it's not work on 11.9.0 (11.4.0 also) , please help me thx!

my pdf image

//======================================================
public static void SignPDF3(DigitallySign Sign, string inFile, string outFile)
{
PKCS7 signature1 = new PKCS7(pbxFile, pbxPwd); // Use PKCS7/PKCS7Detached objects
//create FormEditor object
FormEditor editor = new FormEditor();
editor.BindPdf(inFile);
//add signature fields
editor.AddField(FieldType.Signature, "Signature from Alice", 1, 10, 10, 110, 110);
editor.AddField(FieldType.Signature, "Signature from John", 1, 120, 150, 220, 250);
editor.AddField(FieldType.Signature, "Signature from Smith", 1, 300, 200, 400, 300);
//save the form
editor.Save(outFile);
//add signature to any of the signature fields
PdfFileSignature pdfSign = new PdfFileSignature();
pdfSign.BindPdf(outFile);
//pdfSign.Sign("Signature from John", "Signature Reason", "John", "Kharkov", new PKCS1(dataDir + "temp.pfx", "password"));
pdfSign.Sign("Signature from John", "Signature Reason", "John", "Kharkov", signature1);
//each time new signature is added you must save the document
pdfSign.Save(outFile);
//add second signature
PdfFileSignature pdfSign2 = new PdfFileSignature();
pdfSign2.BindPdf(outFile);
pdfSign2.Sign("Signature from Alice", "Signature Reason", "Alice", "Odessa", signature1);
//each time new signature is added you must save the document
pdfSign2.Save(outFile);
}

Hi there,

Thanks for your inquiry. I have tested the scenario with a sample PFX certificate file using Aspose.Pdf for .NET 11.9.0 and unable to notice the reported issue. Your shared file shows warning message of signature validity instead some error. Please double check the validity of your signature and hopefully this thread of Adobe support forum will be helpful in the scenario.
https://helpx.adobe.com/acrobat/using/validating-digital-signatures.html

Please feel free to contact us for any further assistance.

Best Regards,

hi! thanks reply.

I use the same signature to the two fields.

Signature is no problem in first field. (file:Sign1.pdf)
But when I using a signature to second field , first signature will error :The file has been modified
(file:Sign2.pdf)

please check it. (you can use my test pfx ,password:00000000)

Is there any way to allow duplicate signature it?

or can you share your code or c# project? thanks!

======================================

string pbxFile = @"FelarayPFX.pfx";
string pbxPwd = "00000000";
string inFile = @"cad.pdf";
string outFile = @"cad-o.pdf";
string dataDir = "";

PKCS7 signature1 = new PKCS7(pbxFile, pbxPwd);
PKCS7 signature2 = new PKCS7(pbxFile, pbxPwd);

FormEditor editor = new FormEditor();
editor.BindPdf(inFile);
editor.AddField(FieldType.Signature, "Signature from Alice", 1, 10, 10, 110, 110);
editor.AddField(FieldType.Signature, "Signature from John", 1, 120, 150, 220, 250);
//editor.AddField(FieldType.Signature, "Signature from Smith", 1, 300, 200, 400, 300);
editor.Save(outFile);
//add signature to any of the signature fields
PdfFileSignature pdfSign = new PdfFileSignature();
pdfSign.BindPdf(outFile);
pdfSign.Sign("Signature from John", "1st:Signature Reason", "John", "Kharkov", signature1);
pdfSign.Save(dataDir + @"Sign1.pdf");
//add second signature
PdfFileSignature pdfSign2 = new PdfFileSignature();
pdfSign2.BindPdf(dataDir + @"Sign1.pdf");
pdfSign2.Sign("Signature from Alice", "2nd:Signature Reason", "Alice", "Odessa", signature2);
pdfSign2.Save(dataDir + @"Sign2.pdf");

Hi there,


Thanks for your feedback. I have tested the scenario with your shared certification file and sample code but unable to notice the reported issues. Even I opened your shared Sign2.pdf with Adobe Acrobat XI and did not notice any issue in first signature. Please confirm name an version of your PDF viewer, so we will look further into the issue.

We re sorry for the inconvenience.

Best Regards,
thanks for help. I saw your test is success. and I will check my PDF clinet again .
I open your pdf file in Reader and still error. I'll try open in Acrobat Pro.

thanks again! :)



=====================================

update: In my Acrobat Pro DC, still saw sign error in my pdf. please check my file.(Adobe AcrobatPro.png)

Can you say what version you use? thx

Hi there,


Thanks for sharing additional information. I have tested the signed PDF document using Adobe Reader and noticed it invalidates first signature, whereas it works fine in Adobe Acrobat. I have logged a ticket PDFNET-41446 in our issue tracking system for further investigation and rectification. We will notify you as soon as we resolve it.

We are sorry for the inconvenience.

Best Regards,
hi, how can I to look issue tracking system? I hope to know what time can solved.
thanks.

Hi Felaray,


Thanks for your patience.

The bug tracking system is an internal issue management system and I am afraid you may not be able to access it.

Any news on this issue?
This really gets in a way of our company development plans, and this issue hangs open for quite some time already. Giving the fact that electronic signature importance in day-to-day businesses is increasing, this topic gets hotter every day :frowning:

Signing multiple times PDF document that was
generated with Aspose tools invalidates every previous signature.
We create document of PDF/A type
Our
business process requires to send this document to multiple recipients
and each of them will have to sign same document. However when we try to
do this using Aspose.Pdf tools every previous signature is being
invalidated.
Here I am attaching our test project which includes:
- source code
- docx sample file, which we convert to PDF/A using Aspose.Pdf tools
- certificate file (pfx) which we use in our test to sign the document.

What we have tested is that signing PDF multiple times works using Aspose.Pdf tools, but PDF/A does not. And this is big problem, because of European Union ETSI conformance requirements. As signatures must conform to one of those http://signatures-conformance-checker.etsi.org/pub/index.shtml

bss:
Any news on this issue?
This really gets in a way of our company development plans, and this issue hangs open for quite some time already. Giving the fact that electronic signature importance in day-to-day businesses is increasing, this topic gets hotter every day :frowning:

Signing multiple times PDF document that was
generated with Aspose tools invalidates every previous signature.
We create document of PDF/A type
Our
business process requires to send this document to multiple recipients
and each of them will have to sign same document. However when we try to
do this using Aspose.Pdf tools every previous signature is being
invalidated.
Here I am attaching our test project which includes:
- source code
- docx sample file, which we convert to PDF/A using Aspose.Pdf tools
- certificate file (pfx) which we use in our test to sign the document.

What we have tested is that signing PDF multiple times works using Aspose.Pdf tools, but PDF/A does not. And this is big problem, because of European Union ETSI conformance requirements. As signatures must conform to one of those http://signatures-conformance-checker.etsi.org/pub/index.shtml
Hi Darius,

Thanks for using our API’s.

I have tested the scenario and have managed to reproduce same problem. For the sake of correction, I have separately logged it as PDFNET-41540 in our issue tracking system. We will further look into the details of this problem and will keep you posted on the status of correction. Please be patient and spare us little time. We are sorry for this inconvenience.

hi.

I saw new version (16) for .NET,but still not work on multiple signatures.

It's a big bug for your product. can you check PDFNET-41446 please?


Hi Felaray,


Thanks for your inquiry. I am afraid the issue is still pending for investigation as we have recently logged it. We have recorded your concern and will update you as soon as we made some significant progress towards issue resolution.

Thanks for your patience and cooperation.

Best Regards,
Hello,

1st inquiry on this issue was recorded on 2016.03.10.... thats 6 months from now... We just found same issue, that was reported way way back in time.
The main reason for our company in making decision to renew Aspose licence was your company claims that you support digital signatures and pdf-a formats and here we see what? 6 months in waiting and ZERO actions from devs?
It may look like small annoyance for you, but for companies that develop software for EU countries and decided to choose your components to do their tasks its much much more than that, unfortunately... for us.
Where else we should start exposing this issue so your company development department would start changing their opinion on seriousness of this bug?

Agree,tired of waiting. why can't we waste time on worthwhile somethings?