Copy link to clipboard
Copied
I am converting a HTML file into PDF using evoPDF library in a c# application. This PDF form has multiple textboxes and my requirement is to track keypress event or blur event for these textboxes. I am not able to find syntax on how to write these event handling in Adobe JavaScript. Can someone guide me with these. Your help will be highly appreciated.
Copy link to clipboard
Copied
You can use the setAction method to apply a script to the Keystroke and OnBlur events of the fields.
Copy link to clipboard
Copied
can you please guide me with the syntax to use it,
I am currently trying this:
pdfDocument.Form.Fields["txt_BorrowerHireDate"].Action = new PdfActionJavaScript("if(this.getField('txt_BorrowerHireDate').keyDown==true){app.alert('test');}");
Copy link to clipboard
Copied
Sorry, I'm not familiar with the syntax of your C# library.
Copy link to clipboard
Copied
If you were to write, just the adobe scripts how would you have written it.
Copy link to clipboard
Copied
this.getField("txt_BorrowerHireDate").setAction("MouseDown", "app.alert(\"test\");");
Copy link to clipboard
Copied
However, I think you need to find out how to apply the action directly to the field. What I posted above the code to apply the action using JS, but you wouldn't apply that code to the field itself...
Copy link to clipboard
Copied
Thanks for your help try67, but as you said this is a JS code, I need syntax for adobe javascript (tried the above mentioned syntax but it did not work). Also I tried setting the action on document open and not specific action to the field, but it is not working.
Copy link to clipboard
Copied
Can you see the code in the PDF file when you open the file in Adobe Acrobat?
Copy link to clipboard
Copied
No, code can't be seen. But yes, I am able to log errors.
Copy link to clipboard
Copied
What errors does you get?
Copy link to clipboard
Copied
SyntaxError: missing ) after argument list
1:Doc:Open
Copy link to clipboard
Copied
code: pdfDocument.OpenAction.Action = new PdfActionJavaScript("this.getField('txt_BorrowerHireDate').setAction('MouseDown', 'app.alert('test');');");
Copy link to clipboard
Copied
Try this:
PdfActionJavaScript("this.getField('txt_BorrowerHireDate').setAction('MouseDown', 'app.alert(\'test\');');");