Good morning Paulo.

I want to insert in a existing pdf file a blank signature becouse this pdf will reside in a server and other persons will insert his signature in this blank signature. I work in two codes, one for insert the blank signature and other to insert a signature in this existent pdf with blank signature generated.

In the first code (insert a blank signature) fails when I call to close functions of pdfstamper. Inthe second code, I put the appearance in the blank signature but fails when I built to put the pkcs7 in the content. Pdf is generated but is not a valid :-( , I suposo that I put in the content field an incorrect value.

All samples or information will be helpful.


From: "Paulo Soares" <[EMAIL PROTECTED]>
Reply-To: "Paulo Soares" <[EMAIL PROTECTED]>
To: "Juan Sanchez" <[EMAIL PROTECTED]>,<[email protected]>
Subject: Re: [iText-questions] Add signatures in a existing blank signature
Date: Mon, 8 Aug 2005 16:40:56 +0100

We probably should rewind this thread and start all over again, I'm
confused. What exactly are you trying to do? How would you do that with
Acrobat?

Best Regards,
Paulo Soares

----- Original Message -----
From: "Juan Sanchez" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>; <[email protected]>
Sent: Monday, August 08, 2005 11:36 AM
Subject: Re: [iText-questions] Add signatures in a existing blank signature


>
> Hi Paulo.
>
> I read the PDF reference to nderstand the signature dictionary entries.
> I test inserting next code in the sample to define the filter :
>
>                 ...
> PdfStamper stp = PdfStamper.createSignature(reader, fout,
> '\0', null, true);
>         PdfSignatureAppearance sap = stp.getSignatureAppearance();
>
>                 // begin new coe added
>         PdfDictionary dic = new PdfDictionary();
>         dic.put(PdfName.FT, PdfName.SIG);
>         dic.put(PdfName.FILTER, new PdfName("Adobe.PPKMS"));
> sap.setCryptoDictionary(dic);
>                //end new cod added
>
>                ...
>                stp.close();
>
>
> But the result is the same.Falis when I call the stp.close() function.
>
> I generate a pdf with one blank signature only with acrobat and I don't
find
> any filter value in the pdf when I edit the file.
>
> I can see, in the samples, that all insert the FT, FILTER and SUBFILTER
> fields first and then insert the CONTENTS. But in a blank signature don't
> exist Content to put.
>
> Can you help me to find my error or the part of code that is necessary to
> build a blank signature correctly.
>
> Note : I follow the same steps to built the pdf that in signature.java
> sample that use PdfAcroForm bject. In this sample new document is created > and following the code implementation I search when the filter is put but
i
> have not found it.
>
>
> >From: "Paulo Soares" <[EMAIL PROTECTED]>
> >Reply-To: "Paulo Soares" <[EMAIL PROTECTED]>
> >To: "Juan Sanchez"
> ><[EMAIL PROTECTED]>,<[email protected]>
> >Subject: Re: [iText-questions] Add signatures in a existing blank
signature
> >Date: Fri, 5 Aug 2005 11:25:53 +0100
> >
> >You didn't define the signature filter (PdfName.ADOBE_PPKLITE for
example).
> >You should read the PDF Reference to have a notion on how signatures
work.
> >Start with the examples in howtosign and replace one thing at a time.
> >
> >----- Original Message -----
> >From: "Juan Sanchez" <[EMAIL PROTECTED]>
> >To: <[EMAIL PROTECTED]>; <[email protected]>
> >Sent: Friday, August 05, 2005 8:52 AM
> >Subject: Re: [iText-questions] Add signatures in a existing blank
signature
> >
> >
> > >
> > > Hi Paulo.
> > >
> > > Here the output :
> > >
> > > Before stp.close
> > >
> > > Error
> > >
> > > java.lang.IllegalArgumentException: Unknown filter: null
> > > java.lang.IllegalArgumentException: Unknown filter: null
> > > at
> > >
>
>com.lowagie.text.pdf.PdfSignatureAppearance.preClose(PdfSignatureAppearance
.
> >java:778)
> > > at
> > >
>
>com.lowagie.text.pdf.PdfSignatureAppearance.preClose(PdfSignatureAppearance
.
> >java:717)
> > > at com.lowagie.text.pdf.PdfStamper.close(PdfStamper.java:200)
> > > at
com.lowagie.examples.forms.FormSignature.main(FormSignature.java:125)
> > >
> > >
> > > >From: "Paulo Soares" <[EMAIL PROTECTED]>
> > > >Reply-To: "Paulo Soares" <[EMAIL PROTECTED]>
> > > >To: "Juan Sanchez"
> > > ><[EMAIL PROTECTED]>,<[email protected]>
> > > >Subject: Re: [iText-questions] Add signatures in a existing blank
> >signature
> > > >Date: Thu, 4 Aug 2005 13:27:59 +0100
> > > >
> > > >What's the stack trace?
> > > >
> > > >----- Original Message -----
> > > >From: "Juan Sanchez" <[EMAIL PROTECTED]>
> > > >To: <[EMAIL PROTECTED]>; <[email protected]>
> > > >Sent: Thursday, August 04, 2005 10:07 AM
> > > >Subject: Re: [iText-questions] Add signatures in a existing blank
> >signature
> > > >
> > > >
> > > > >
> > > > > Hi Paulo
> > > > >
> > > > > Another question about blank signatures.
> > > > > I test with the code sample from the question [iText-questions]
> >Adding
> > > >Blank
> > > > > Signature Field gives problem ,  but the program return me an
error
> >in
> > > >the
> > > > > close function  stp.close();
> > > > > As you commented I put the same code used in the
> >AcroForm.AddSignature
> > > >usgn
> > > > > the addAnnotation from PdfStamper.
> > > > >
> > > > > What's the problem  ?
> > > > >
> > > > >   PdfReader reader = new PdfReader("blank3.pdf");
> > > > >     FileOutputStream fout = new FileOutputStream("signed.pdf");
> > > > >
> > > > >     int lx = 50 ;
> > > > >     int ly = 50 ;
> > > > >     int ux = 100 ;
> > > > >     int uy = 100 ;
> > > > >
> > > > > PdfStamper stp = PdfStamper.createSignature(reader,
> >fout,
> > > > > '\0', null, true);
> > > > >     PdfSignatureAppearance sap = stp.getSignatureAppearance();
> > > > >
> > > > >     PdfWriter writer = stp.getWriter();
> > > > >     PdfFormField sig = PdfFormField.createSignature(writer);
> > > > >
> > > > >     stp.addAnnotation(sig, 1);
> > > > >     sig.setWidget(new Rectangle(lx, ly, ux, uy),
> > > > > PdfAnnotation.HIGHLIGHT_INVERT);
> > > > >     sig.setFlags(PdfAnnotation.FLAGS_PRINT);
> > > > >     sig.put(PdfName.DA, new PdfString("/Helv 0 Tf 0 g"));
> > > > >     sig.setFieldName("SignatureBLANK");
> > > > >     sig.setPage();
> > > > >                 sig.setMKBorderColor(java.awt.Color.black);
> > > > >                 sig.setMKBackgroundColor(java.awt.Color.white);
> > > > >
> > > > >         PdfContentByte cb = writer.getDirectContent();
> > > > >         PdfAppearance tp = cb.createAppearance(ux-lx, uy-ly);
> > > > >         tp.setGrayFill(1.0f);
> > > > >         tp.rectangle(0, 0, ux-lx, uy-ly);
> > > > >         tp.fill();
> > > > >         tp.setGrayStroke(0);
> > > > >         tp.setLineWidth(1);
> > > > >         tp.rectangle(0.5f, 0.5f, ux-lx - 0.5f, uy - ly - 0.5f);
> > > > >         tp.closePathStroke();
> > > > >         tp.saveState();
> > > > >         tp.rectangle(1, 1, ux-lx - 2, uy - ly - 2);
> > > > >         tp.clip();
> > > > >         tp.newPath();
> > > > >         tp.restoreState();
> > > > >         sig.setAppearance(PdfAnnotation.APPEARANCE_NORMAL, tp);
> > > > >
> > > > >         stp.addAnnotation(sig, 1);
> > > > >         stp.close();
> > > > >
> > > > > Best regards in advance.
> > > > >
> > > > >
> > > > > >From: "Paulo Soares" <[EMAIL PROTECTED]>
> > > > > >Reply-To: "Paulo Soares" <[EMAIL PROTECTED]>
> > > > > >To: "Juan Sanchez"
> > > > > ><[EMAIL PROTECTED]>,<[email protected]>
> > > > > >Subject: Re: [iText-questions] Add signatures in a existing blank
> > > >signature
> > > > > >Date: Wed, 3 Aug 2005 16:41:34 +0100
> > > > > >
> > > > > >Signatures must be done one at a time, that's the way PDFs work.
Do
> >the
> > > > > >next
> > > > > >signatures in append mode (as you did in your code). You can have
> > > >external
> > > > > >signatures or even a full external PKCS#7, see the examples.
> > > > > >
> > > > > >----- Original Message -----
> > > > > >From: "Juan Sanchez" <[EMAIL PROTECTED]>
> > > > > >To: <[EMAIL PROTECTED]>;
<[email protected]>
> > > > > >Sent: Wednesday, August 03, 2005 3:27 PM
> > > > > >Subject: Re: [iText-questions] Add signatures in a existing blank
> > > >signature
> > > > > >
> > > > > >
> > > > > > >
> > > > > > > Hi Paulo.
> > > > > > >
> > > > > > > After execute the next code , in the pdf document (that
contain
> >3
> > > >blank
> > > > > > > signatures) only appear 1 signed and the others continue
> >empties.
> > > > > > > What is the problem ? is it necessary to close document
> >everytime
> >?
> > > > > > >
> > > > > > >     PdfReader reader = new PdfReader("blank_3.pdf");
> > > > > > >     FileOutputStream fout = new
FileOutputStream("signed.pdf");
> > > > > > >
> > > > > > >         PRAcroForm form = reader.getAcroForm();
> > > > > > >         if (form == null){
> > > > > > >             System.out.println("This document has no
fields.");
> > > > > > >             return;
> > > > > > >         }
> > > > > > >
> > > > > > >         // prepare keyStore
> > > > > > >         KeyStore ks = KeyStore.getInstance("pkcs12");
> > > > > > >         ks.load(new FileInputStream("myCert.p12"),
> > > > > >"mypass".toCharArray());
> > > > > > >         String alias = (String)ks.aliases().nextElement();
> > > > > > >         PrivateKey key = (PrivateKey)ks.getKey(alias,
> > > > > > > "mypass".toCharArray());
> > > > > > >         Certificate[] chain = ks.getCertificateChain(alias);
> > > > > > >
> > > > > > >         PdfStamper stp = PdfStamper.createSignature(reader,
> >fout,
> > > >'\0',
> > > > > > > null, true);
> > > > > > >         AcroFields af = stp.getAcroFields();
> > > > > > >         ArrayList names = af.getBlankSignatureNames();
> > > > > > >         for (int k = 0; k < names.size(); ++k) {
> > > > > > > String name = (String)names.get(k);
> > > > > > > System.out.println("Signature name: " + name);
> > > > > > >
> > > > > > > PdfSignatureAppearance sap = stp.getSignatureAppearance();
> > > > > > > sap.setCrypto(key, chain, null,
> > > >PdfSignatureAppearance.WINCER_SIGNED);
> > > > > > > sap.setReason("MyReasons");
> > > > > > > sap.setLocation("MyLocation");
> > > > > > > sap.setVisibleSignature(name);
> > > > > > >         }
> > > > > > >         stp.close();
> > > > > > >     }
> > > > > > >     catch(Exception e ){
> > > > > > >     System.out.println("\n\t" + e.toString());
> > > > > > >     }
> > > > > > >     }
> > > > > > >
> > > > > > >
> > > > > > > Regards.
> > > > > > >
> > > > > > >
> > > > > > > >From: "Paulo Soares" <[EMAIL PROTECTED]>
> > > > > > > >Reply-To: "Paulo Soares" <[EMAIL PROTECTED]>
> > > > > > > >To: "Juan Sanchez"
> > > > > > > ><[EMAIL PROTECTED]>,<[email protected]>
> > > > > > > >Subject: Re: [iText-questions] Add signatures in a existing
> >blank
> > > > > >signature
> > > > > > > >Date: Wed, 3 Aug 2005 11:09:01 +0100
> > > > > > > >
> > > > > > > >See http://itextpdf.sf.net/howtosign.html. To sign an
existing
> > > >field
> > > > > >use
> > > > > > > >PdfSignaturaAppearance.setVisibleSignature(String).
> > > > > > > >
> > > > > > > >----- Original Message -----
> > > > > > > >From: "Juan Sanchez" <[EMAIL PROTECTED]>
> > > > > > > >To: <[email protected]>
> > > > > > > >Sent: Wednesday, August 03, 2005 9:38 AM
> > > > > > > >Subject: [iText-questions] Add signatures in a existing blank
> > > >signature
> > > > > > > >
> > > > > > > >
> > > > > > > > > Hi.
> > > > > > > > >
> > > > > > > > > I want to insert a signature in a blank signature created
> > > > > >previously.
> > > > > > > > > Is there some example that it can help me ?
> > > > > > > > >
> > > > > > > > > Regards.
> > > > > > > > >
> > > > > > > > >
> > > >_________________________________________________________________
> > > > > > > > > Don't just search. Find. Check out the new MSN Search!
> > > > > > > > > http://search.msn.com/
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > -------------------------------------------------------
> > > > > > > > > SF.Net email is sponsored by: Discover Easy Linux
Migration
> > > > > >Strategies
> > > > > > > > > from IBM. Find simple to follow Roadmaps, straightforward
> > > >articles,
> > > > > > > > > informative Webcasts and more! Get everything you need to
> >get
> >up
> > > >to
> > > > > > > > > speed, fast.
> > > >http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
> > > > > > > > > _______________________________________________
> > > > > > > > > iText-questions mailing list
> > > > > > > > > [email protected]
> > > > > > > > >
https://lists.sourceforge.net/lists/listinfo/itext-questions
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > >-------------------------------------------------------
> > > > > > > >SF.Net email is sponsored by: Discover Easy Linux Migration
> > > >Strategies
> > > > > > > >from IBM. Find simple to follow Roadmaps, straightforward
> >articles,
> > > > > > > >informative Webcasts and more! Get everything you need to get
> >up
> >to
> > > > > > > >speed, fast.
> > > >http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
> > > > > > > >_______________________________________________
> > > > > > > >iText-questions mailing list
> > > > > > > >[email protected]
> > > > > > > >https://lists.sourceforge.net/lists/listinfo/itext-questions
> > > > > > >
> > > > > > >
> >_________________________________________________________________
> > > > > > > Don't just search. Find. Check out the new MSN Search!
> > > > > > > http://search.msn.click-url.com/go/onm00200636ave/direct/01/
> > > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > >-------------------------------------------------------
> > > > > >SF.Net email is sponsored by: Discover Easy Linux Migration
> >Strategies
> > > > > >from IBM. Find simple to follow Roadmaps, straightforward
articles,
> > > > > >informative Webcasts and more! Get everything you need to get up
to
> > > > > >speed, fast.
> >http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
> > > > > >_______________________________________________
> > > > > >iText-questions mailing list
> > > > > >[email protected]
> > > > > >https://lists.sourceforge.net/lists/listinfo/itext-questions
> > > > >
> > > > > _________________________________________________________________
> > > > > Express yourself instantly with MSN Messenger! Download today -
it's
> > > >FREE!
> > > > > http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/
> > > > >
> > > >
> > >
> > > _________________________________________________________________
> > > Don't just search. Find. Check out the new MSN Search!
> > > http://search.msn.click-url.com/go/onm00200636ave/direct/01/
> > >
> >
>
> _________________________________________________________________
> Express yourself instantly with MSN Messenger! Download today it's FREE!
> http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/
>


_________________________________________________________________
Don't just search. Find. Check out the new MSN Search! http://search.msn.com/



-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Reply via email to