Hi!
I'm trying to add a javascript action to a text field to check the
date is properly written. I've got an example:
/****** EXAMPLE *********/
TextField textfield = new TextField(writer, new Rectangle(40, 790,
300, 810), "uppercase");
...
PdfFormField field = textfield.getTextField();
String datechecker = "this.getField(\"uppercase\").setAction(
\"Keystroke\", \"AFDate_KeystrokeEx( 'dd-mmm-yyyy' )\" ) ;\r";
PdfAction validator = PdfAction.javaScript( datechecker, writer );
field.setAction( validator);
/*****************************/
It works fine, but when I want to do something like this using an
existing PDF form, I get stuck. First of all, in that case I don't
have a writer, neither a field. So I'm trying with something like:
/****** EXAMPLE *********/
...
PdfCopy copy = new PdfCopy(document,new FileOutputStream("result.pdf"));
document.open();
for (int i = 0; i < pages; ) {
++i;
copy.addPage(copy.getImportedPage (reader, i));
}
...
String datechecker = "this.getField(\"tfFecha\").setAction(
\"Keystroke\", \"AFDate_KeystrokeEx( 'dd-mmm-yyyy' )\" ) ;\r";
PdfAction validator = PdfAction.javaScript( datechecker, copy );
/************* IT'S THIS OK?? *************************/
/**************************************** WHAT SHOULD BE WRITTEN HERE
******************************************/
I need some help!
Thanks
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://itext.ugent.be/itext-in-action/