Thanks
I really appreciate your help.

Please find my comments inline.
On Thu, Jul 9, 2009 at 8:30 PM, Leonard Rosenthol <lrose...@adobe.com>wrote:

>  You can do dynamic images in AcroForms using push button appearances – so
> when you using iText to modify the form, you can embed the image at that
> time.  -- I want really dynamic. Earlier I tried to embed the image but it
> didn't flew with my manager. :)
>


>  Or if you really wanted something more dynamic, you can also use SOAP
> calls from the JavaScript to fetch the image on the fly and assign it to the
> button. -- I followed exactly what your are suggesting the pushbutton
> appearance approach. You r great.
>
Using iText I added this js code on button click:

var response = SOAP.request(
  {
 cURL: 'http://10.150.3.131:8080/TestClientWS/services/RegFortAdminSvc',
 oRequest: {'http://stubs.admin.regfort.arcot.com:GetPAMImage':{name:'ABCD'}
},
  bEncoded: false,
 cNamespace: 'http://stubs.admin.regfort.arcot.com',
 cResponseStyle: SOAPMessageStyle.Message
 }
);

console.show();
var imgValue = response[0].soapValue[0].soapValue;
var srcStream = SOAP.streamFromString(imgValue);
var decodedStream = SOAP.streamDecode(srcStream,\"base64\");
console.println(this.getField(\"Confirm\").buttonGetCaption());
app.alert(this.getField(\"Confirm\").buttonGetCaption());
var f = this.getField(\"Confirm\");
f.buttonSetCaption(\"Hello\");
f.buttonSetIcon(decodedStream);    //It requires an Icon object but I am not
able to create an Icon obj from stream.

Leonard I am able to set the the buttons caption but not the image. Please
help me on this.

>   Leonard
>
>
>
> *From:* Harshit Bapna [mailto:hrba...@gmail.com]
> *Sent:* Thursday, July 09, 2009 10:49 AM
>
> *To:* Post all your questions about iText here
> *Subject:* Re: [iText-questions] Issue faced while PDFStamping on a XFA
> Form (having javascript) .
>
>
>
> Please find my comments inline
>
> On Thu, Jul 9, 2009 at 7:42 PM, Leonard Rosenthol <lrose...@adobe.com>
> wrote:
>
>  What do you mean that the image is passed from server?  As you are
> building/modifying the PDF, right?  It’s not coming up dynamically when the
> document loads – that’s not supported any longer (since Acrobat 8, IIRC).
>
>  The server is sending  base64 encoded string and the requirement is that
> the ArcotForm js would assign this encoded string to the image and hence
> displays an image at runtime.
>
> You are correct. I followed this approach as reader 8.1(Security update
> from adobe) or later doesn't allow the HREF approach.
>
>
>
> This is the reason why I want to use XFA form as I was able to achieve
> runtime image display by using ImageField not by AcroForm.
>
>
>
> You can only have one type of form in a PDF – either AcroForm or XFA, you
> can NOT have both.  As long as you have XFA, that will cause Acrobat/Reader
> to ignore any AcroForms that you have created. In your case, that’s the
> pushbutton, which is why it doesn’t work in #3, because as far as
> Acrobat/Reader is concerned, it doesn’t exist.  If you want to add a button
> to your XFA-based form, that’s fine too – you just have to do it using lower
> level functionality with iText and XFA/XML.
>
>  I was just hoping that I can include both the forms as before this xfa
> approach the whole application was using iText to create PDF but as you are
> guiding the acroform won't be recognized. I was wrong in choosing this
> approach :(
>
>    I was using XFA form to only display the image rest everything is done
> through Acroform(iText) .
>
>
>
> Can you give any work around or suggestion to achieve this?
>
>
>
> Leonard
>
>
>
> *From:* Harshit Bapna [mailto:hrba...@gmail.com]
> *Sent:* Thursday, July 09, 2009 9:48 AM
>
>
> *To:* Post all your questions about iText here
> *Subject:* Re: [iText-questions] Issue faced while PDFStamping on a XFA
> Form (having javascript) .
>
>
>
> Hi All,
>
>
>
> Leonard, Thanks for the reply.
>
>
>
>  Few more additions.
>
> 1) I stamped a pushbutton and javascripts invoked on the buttonClick and
> documentOpen event (using iText) on a XFA form PDF (created using designer
> 8.2) which already had a button and javascript invoked on a button click
> event.
>
>
>
> In the final output :
>
> 1. javascript on button(created using Designer) -- *working*
>
> 2. javascript is getting invoked on document open event(this js was added
> using iText) -- *working*
>
> 3. javascript on button(created using itext) -- *not working*
>
>
>
> This makes me believe that the js on the button is not getting propely set.
> (code in the below mail)
>
> 1) Is it not the case?
>
> 2) Is this XFA-Acroform apporach not feasible ?
>
>
>
> I am deliberately using the XFA form as I wanted to have runtime
> image(base64 encoded string passed from server) display functionality which
> I was able to do using XFA ImageField property.
>
>
>
> --harshit
>
>
>
>
>
> On Thu, Jul 9, 2009 at 5:52 PM, Leonard Rosenthol <lrose...@adobe.com>
> wrote:
>
> And you can't mix XFA and AcroForm - which is what you are trying to do
> (since PushButton is AcroForm).
>
> Leonard
>
>
> -----Original Message-----
> From: Paulo Soares [mailto:psoa...@glintt.com]
> Sent: Thursday, July 09, 2009 5:01 AM
> To: Post all your questions about iText here
> Subject: Re: [iText-questions] Issue faced while PDFStamping on a XFA Form
> (having javascript) .
>
> If you're using a XFA all you can do is fill the fields, that's all iText
> supports.
>
> Paulo
>
> > -----Original Message-----
> > From: Harshit Bapna [mailto:hrba...@gmail.com]
> > Sent: Thursday, July 09, 2009 9:14 AM
> > To: itext-questions@lists.sourceforge.net
> > Subject: [iText-questions] Issue faced while PDFStamping on a XFA Form
> > (having javascript) .
> >
> > Hi All,
> >
> > Summary of the Issue: To display an image in PDF at runtime.
> > Limitation: The image cannot be embeded into PDF.
> >
> > Approaches:
> > 1) Using iText and AcroForm I was not able to achieve this.
> > -- Not successfull
> > 2) I designed a form using LC Designer with an ImageField. I assigned
> > the Base64 encoded string to the raw value of this ImageField. It
> > worked -- Successfull
> >
> > I have lot of working code created using iText so I didn't wanted to
> > tamper them. So I came up with this appporach that I would create a
> > base PDF(XFA) using Designer and use PDFStamper to add javascript,
> > button, image, texts.
> >
> > Questions:
> > 1) Is this approach correct/ feasible ?
> >
> > 2) My XFA Pdf (created using Designer) has a javascript. I take this
> > pdf as a base pdf and add a button and document javascript on a button
> > click(suing iText).
> > In the final pdf the button javascript doesn't work.
> >
> > Note: Please be assured that both document javascript and xfa
> > javascript are fine and running but only when they are merged the doc
> > javascript doesn't work.
> > Also I am able to run a document javascript on DOCUMENT OPEN Event but
> > the javascript on button click is not being invoked.
> >
> >
> > Please guide me on the probable cause of the issue? Code Snippet below
> >
> >
> > Code Snippet:
> > public static void main(String[] args) {
> >   try {
> >        PdfReader reader = new PdfReader("C:\\Documents and
> > Settings\\harshit\\Desktop\\baseXFA.pdf");//HelloWorldForm.pdf
> >  HelloWorldForm1.pdf baseXFA.pdf
> >        PdfStamper stamper = new PdfStamper(reader, new
> > FileOutputStream("C:\\Documents and
> > Settings\\harshit\\Desktop\\baseXFAStamped.pdf"));
> >        PdfWriter writer = stamper.getWriter();
> >       XfaForm form = new XfaForm(reader);
> >       System.out.println("XFA Present:" + form.isXfaPresent());
> >       //form.setXfa(writer);
> >       // parsing the dom document and set the values for the required
> > fields
> >       //Document modifiedDoc = parseXdp(form.getDomDocument());
> >
> > stamper.setPageAction(PdfWriter.PAGE_OPEN,PdfAction.javaScript("" +
> >                     "try{" +
> >                     " app.alert(\"doc ready event captured\");"+
> >                     " this.submitActionX();"+
> >                     "}catch(e){}" ,writer),1);
> >
> >       writer.addJavaScript("function submitActionX() {" +
> >       "   console.show();"  +
> >                   "   console.println('---------------------');"  +
> >       " var f = this.getField(\"authX\");"+
> >                   "  f.buttonSetCaption(\"Xhtua\");"+
> >       //"   this.getField(\"userName\").value=\"harshit\";" +
> >                 " }"
> >       );
> >       PushbuttonField button = new PushbuttonField(writer,
> >         new Rectangle(400, 425, 450, 440), "authX"); //230,
> > 80, 360, 110   400, 425, 450, 440   400, 80, 450, 100  230,
> > 150, 360, 160
> >       button.setText("AuthX");
> >       button.setOptions(PushbuttonField.VISIBLE_BUT_DOES_NOT_PRINT);
> >       button.setBackgroundColor(Color.decode("#333399"));
> >       button.setTextColor(Color.WHITE);
> >       button.setBorderStyle(PdfBorderDictionary.STYLE_BEVELED);
> >       button.setBorderWidth(1);
> >       PdfFormField submit = button.getField();
> >       PdfAction ac =
> > PdfAction.javaScript("this.submitActionX();"  , writer);//
> > form1.authForm.jsex.displayPAMImage() this.open();
> >       //PdfAction ac = PdfAction.javaScript("app.alert('click
> > event captured');"  , writer);//
> > form1.authForm.jsex.displayPAMImage() this.open();
> >       submit.setAction(ac);
> >       stamper.addAnnotation(submit, 1);
> >       BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA,
> >       BaseFont.WINANSI, BaseFont.NOT_EMBEDDED);
> >       TextField tf = new TextField(writer, new Rectangle(300,480, 370,
> > 490), "userName");//67, 500, 340, 800
> >       tf.setFontSize(12);
> >       tf.setFont(bf);
> >       tf.setText("Jaya Kumar");
> >       tf.setTextColor(new GrayColor(0.5f));
> >       stamper.addAnnotation(tf.getTextField(),1);
> >       //stamper.setFormFlattening(true);
> >       stamper.close();
> >   } catch (IOException e) {
> >       e.printStackTrace();
> >   } catch (DocumentException e) {
> >       e.printStackTrace();
> >   } catch (ParserConfigurationException e) {
> >    // TODO Auto-generated catch block
> >       e.printStackTrace();
> >   } catch (SAXException e) {
> >    // TODO Auto-generated catch block
> >      e.printStackTrace();
> >   }
> >  }
> >
> > Thanks
> >
> >
> >
>
> Aviso Legal: Esta mensagem ? destinada exclusivamente ao destinat?rio. Pode
> conter informa??o confidencial ou legalmente protegida. A incorrecta
> transmiss?o desta mensagem n?o significa a perca de confidencialidade. Se
> esta mensagem for recebida por engano, por favor envie-a de volta para o
> remetente e apague-a do seu sistema de imediato. ? proibido a qualquer
> pessoa que n?o o destinat?rio de usar, revelar ou distribuir qualquer parte
> desta mensagem.   Disclaimer: This message is destined exclusively to the
> intended receiver. It may contain confidential or legally protected
> information. The incorrect transmission of this message does not mean the
> loss of its confidentiality. If this message is received by mistake, please
> send it back to the sender and delete it from your system immediately. It is
> forbidden to any person who is not the intended receiver to use, distribute
> or copy any part of this message.
>
>
>
> ------------------------------------------------------------------------------
> Enter the BlackBerry Developer Challenge
> This is your chance to win up to $100,000 in prizes! For a limited time,
> vendors submitting new applications to BlackBerry App World(TM) will have
> the opportunity to enter the BlackBerry Developer Challenge. See full prize
> details at: http://p.sf.net/sfu/Challenge
> _______________________________________________
> iText-questions mailing list
> iText-questions@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/itext-questions
>
> Buy the iText book: http://www.1t3xt.com/docs/book.php
> 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/
>
>
>
>
> --
> -- Harshit Bapna
>
>
>
> ------------------------------------------------------------------------------
> Enter the BlackBerry Developer Challenge
> This is your chance to win up to $100,000 in prizes! For a limited time,
> vendors submitting new applications to BlackBerry App World(TM) will have
> the opportunity to enter the BlackBerry Developer Challenge. See full prize
> details at: http://p.sf.net/sfu/Challenge
> _______________________________________________
> iText-questions mailing list
> iText-questions@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/itext-questions
>
> Buy the iText book: http://www.1t3xt.com/docs/book.php
> 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/
>
>
>
>
> --
> -- Harshit Bapna
>
>
> ------------------------------------------------------------------------------
> Enter the BlackBerry Developer Challenge
> This is your chance to win up to $100,000 in prizes! For a limited time,
> vendors submitting new applications to BlackBerry App World(TM) will have
> the opportunity to enter the BlackBerry Developer Challenge. See full prize
> details at: http://p.sf.net/sfu/Challenge
> _______________________________________________
> iText-questions mailing list
> iText-questions@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/itext-questions
>
> Buy the iText book: http://www.1t3xt.com/docs/book.php
> 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/
>



-- 
-- Harshit Bapna
------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge  
This is your chance to win up to $100,000 in prizes! For a limited time, 
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize  
details at: http://p.sf.net/sfu/Challenge
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.1t3xt.com/docs/book.php
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/

Reply via email to