You have a new class to create buttons in http://itextpdf.sf.net or in the
CVS. To use it:

Document document = new Document(PageSize.A4, 50, 50, 50, 50);
PdfWriter writer = PdfWriter.getInstance(document, new
FileOutputStream("output.pdf"));
document.open();
PdfContentByte cb = writer.getDirectContent();
Image img = Image.getInstance("image.png");
PushbuttonField bt = new PushbuttonField(writer, new Rectangle(100, 100,
200, 200), "Button1");
bt.setText("My Caption");
bt.setFontSize(0);
bt.setImage(img);
bt.setLayout(PushbuttonField.LAYOUT_ICON_TOP_LABEL_BOTTOM);
bt.setBackgroundColor(Color.cyan);
bt.setBorderStyle(PdfBorderDictionary.STYLE_SOLID);
bt.setBorderColor(Color.red);
bt.setBorderWidth(3);
PdfFormField ff = bt.getButton();
PdfAction ac = PdfAction.createSubmitForm("http://www.submit-site.com";,
null, 0);
ff.setAction(ac);
writer.addAnnotation(ff);
document.close();


----- Original Message ----- 
From: "Guillermo Odone" <[EMAIL PROTECTED]>
To: <[email protected]>; <[EMAIL PROTECTED]>
Sent: Tuesday, March 22, 2005 5:23 AM
Subject: [iText-questions] Hi everyone!


I'm having a little problem with Acobat 7 and the Submit Button.
I'm making a web app which allows any pdf form created by the client, and
process the data (creates a search for the fields, makes all the inserts and
updates in a SQL Database, and only saves one PDF as a template, the rest is
saved in the SQL DB.)

I know that iText does not support XFA so I used the code from the forum to
remove it; after that the submit button is useless, and I need it.
The thing is that I'm not the one who will create the forms (the client will
do them), and so, I need to restore the clients submit button as it was
before the removal of the XFA (I don't care about the url, cause I overwrite
the clients url with my own to process the form).

I tried this in order to create a new submit button, but it seems to be
missing something more.

-> PdfFormField pff = PdfFormField.createPushButton( stamp.getWriter() ) ;
-> pff.setAction( new PdfAction( PdfAction.SUBMIT_HTML_FORMAT ) ) ;
-> PdfDictionary a = (PdfDictionary)PdfReader.getPdfObject( pff.get(
PdfName.A ) ) ;
-> PdfDictionary f = new PdfDictionary() ;
-> f.put( PdfName.FS, PdfName.URL ) ;
-> f.put( PdfName.F, new PdfString("http://www.mdssol.com";) ) ;
-> a.put( PdfName.F, f ) ;
->
-> pff.setWidget( new Rectangle( 100, 100, 150, 150 ),
PdfAnnotation.HIGHLIGHT_PUSH ) ;
-> pff.setFieldName( "fldname" ) ;
-> pff.setFieldFlags( PdfFormField.FF_PUSHBUTTON ) ;
-> pff.setMKAlternateCaption( "Alter Enviar" ) ;
->
-> PdfAppearance pa = cb.createAppearance( 50, 50 ) ;
-> pa.setColorFill( java.awt.Color.red ) ;
-> pa.setColorStroke( java.awt.Color.blue ) ;
-> pa.drawButton( 100, 100, 150, 150, "Enviar", BaseFont.createFont(
BaseFont.HELVETICA, BaseFont.WINANSI, false ), 12 ) ;
-> pff.setAppearance( PdfAnnotation.APPEARANCE_NORMAL, pa ) ;
->
-> stamp.addAnnotation( pff, 1 ) ;

Thanks for all in advance!
Guillermo Odone.



-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Reply via email to