First of all, thank you very much for your quick answer.
Finally, I found the solution to my problem. The attached source works fine.
// Get the first time signed pdf
PdfReader reader = new
PdfReader(LeerPDF.class.getResourceAsStream("cas[signed].pdf"));
ByteArrayOutputStream out = new ByteArrayOutputStream();
reader = new PdfReader(reader);
// work with new revision each time
PdfStamper stp1 = new PdfStamper(reader, out, '\3',
true);
PdfFormField sig =
PdfFormField.createSignature(stp1.getWriter());
sig.setWidget(new Rectangle(300, 400, 400, 500), null);
sig.setFlags(PdfAnnotation.FLAGS_PRINT);
sig.put(PdfName.DA, new PdfString("/Helv 0 Tf 0 g"));
sig.setFieldName("Signature4");
sig.setPage(1);
// Attached the blank signature field to the existing
document
stp1.addAnnotation(sig, 1);
stp1.addAnnotation(sig, 2);
stp1.close();
out.close();
FileOutputStream fout = new FileOutputStream
("c:\\cas[signed][signed].pdf");
reader = new PdfReader(out.toByteArray());
// Fill the new signature fields in the correct pdf
revision
PdfStamper stp = PdfStamper.createSignature(reader, fout,
'\3', null,
true);
PdfSignatureAppearance sap =
stp.getSignatureAppearance();
sap.setCrypto(getPrivateKey(), chain, null,
PdfSignatureAppearance.SELF_SIGNED);
sap.setReason("RAZON");
sap.setLocation("UBICACION");
sap.setLayer2Text("Texto");
sap.setAcro6Layers(true);
// Set visible signature field
sap.setVisibleSignature("Signature4");
// Close PdfStamper and output
stp.close();
fout.close();
The result is:
http://old.nabble.com/file/p28385778/cas%255Bsigned%255D%255Bsigned%255D.pdf
cas%5Bsigned%5D%5Bsigned%5D.pdf
If I want to sign again this document I have to work with a different
revision, so the previous signatures appears not modified.
Regards
mkl wrote:
>
> tobras,
>
>
> tobras wrote:
>>
>> I have to make multiple pdf signatures with visible sign fields in all
>> pages.
>>
>> This process is based in two times digital signature and attach first
>> time one signed field in each page and the second time attach other new
>> singed field in all pages, too.
>>
>> With itext the first time i get a quite well result:
>>
>> http://old.nabble.com/file/p28374926/cas%255Bsigned%255D.pdf
>> cas%5Bsigned%5D.pdf
>>
>> But second time when I add the blank new field and sign it, the previous
>> signature appears corrupted.
>>
>
> It sure would be easier for us to try and help you if you attached an
> example result of the second signature applied your way. An additional bit
> of sample code would make everything complete.
>
> Merely looking at the samples you gave I can only say that the way the
> multi-page signatures is not 100% clean --- you have a P value pointing to
> the first page dictionary in the one annotation/field dictionary which
> actually is attached as annotation to the page dictionaries of both pages.
> Thus, in case of the second page, the P value is wrong. Acrobat and Reader
> don't seem to care, though.
>
> In my eyes it would be best not to have field and annotation dictionary
> merged. Instead having one field dictionary with one individual widget
> annotation dictionary for each page would be a cleaner approach.
>
> Regards, Michael.
>
--
View this message in context:
http://old.nabble.com/Multiple-pdf-sign-in-all-pages-with-itext-tp28374926p28385778.html
Sent from the iText - General mailing list archive at Nabble.com.
------------------------------------------------------------------------------
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://www.itextpdf.com/book/
Check the site with examples before you ask questions:
http://www.1t3xt.info/examples/
You can also search the keywords list: http://1t3xt.info/tutorials/keywords/