• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers

Using JavaScripts to handle keypress events

Community Beginner ,
Feb 12, 2019 Feb 12, 2019

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.

TOPICS
Acrobat SDK and JavaScript , Windows

Views

1.4K

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 12, 2019 Feb 12, 2019

Copy link to clipboard

Copied

You can use the setAction method to apply a script to the Keystroke and OnBlur events of the fields.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Feb 12, 2019 Feb 12, 2019

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');}");

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 12, 2019 Feb 12, 2019

Copy link to clipboard

Copied

Sorry, I'm not familiar with the syntax of your C# library.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Feb 12, 2019 Feb 12, 2019

Copy link to clipboard

Copied

If you were to write, just the adobe scripts how would you have written it.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 12, 2019 Feb 12, 2019

Copy link to clipboard

Copied

this.getField("txt_BorrowerHireDate").setAction("MouseDown", "app.alert(\"test\");");

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 12, 2019 Feb 12, 2019

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...

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Feb 20, 2019 Feb 20, 2019

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.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 20, 2019 Feb 20, 2019

Copy link to clipboard

Copied

Can you see the code in the PDF file when you open the file in Adobe Acrobat?

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Feb 20, 2019 Feb 20, 2019

Copy link to clipboard

Copied

No, code can't be seen. But yes, I am able to log errors.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 20, 2019 Feb 20, 2019

Copy link to clipboard

Copied

What errors does you get?

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Feb 20, 2019 Feb 20, 2019

Copy link to clipboard

Copied

SyntaxError: missing ) after argument list

1:Doc:Open

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Feb 20, 2019 Feb 20, 2019

Copy link to clipboard

Copied

code: pdfDocument.OpenAction.Action = new PdfActionJavaScript("this.getField('txt_BorrowerHireDate').setAction('MouseDown', 'app.alert('test');');");

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 20, 2019 Feb 20, 2019

Copy link to clipboard

Copied

LATEST

Try this:

PdfActionJavaScript("this.getField('txt_BorrowerHireDate').setAction('MouseDown', 'app.alert(\'test\');');");

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines