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

User to highlight words by clicking on text

Community Beginner ,
Apr 15, 2021 Apr 15, 2021

Copy link to clipboard

Copied

I have a fillable form all ready to go except for one thing.  I am looking to make certain words "highlightable" or just a plain underline by the user just clicking on it.  Is this possible? I am very new to this and no nothing about programming.

TOPICS
Create PDFs , Edit and convert PDFs , How to , PDF forms

Views

1.4K

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

correct answers 1 Correct answer

Community Expert , Apr 16, 2021 Apr 16, 2021

You need a script for it. But in order to write the script you first need to find out the "name" of the comment.

To do that you need to select the comment by clicking it, then open the JS Console (Ctrl+J), and enter the following code into it and press Ctrl+Enter:

 

selectedAnnots[0].name

 

It will print out something like this:

1f7dc8a2-7702-4bca-a7f7-8ee7bb664c53

Copy that string and enter it into the following code, as the Mouse Up event of the button:

 

var a = this.getAnnot(event.target.pag

...

Votes

Translate

Translate
Community Expert ,
Apr 15, 2021 Apr 15, 2021

Copy link to clipboard

Copied

It's possible, but not that simple. It would require creating a highlight comment and a button over the text.

The button can then be used to show/hide the highlight comment each time you click it.

Votes

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 ,
Apr 15, 2021 Apr 15, 2021

Copy link to clipboard

Copied

So, I've created the highlight comment and a button over it.  When I click on it, it does nothing.  How do I make it so it will show and hide the highlight?

Votes

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 ,
Apr 16, 2021 Apr 16, 2021

Copy link to clipboard

Copied

You need a script for it. But in order to write the script you first need to find out the "name" of the comment.

To do that you need to select the comment by clicking it, then open the JS Console (Ctrl+J), and enter the following code into it and press Ctrl+Enter:

 

selectedAnnots[0].name

 

It will print out something like this:

1f7dc8a2-7702-4bca-a7f7-8ee7bb664c53

Copy that string and enter it into the following code, as the Mouse Up event of the button:

 

var a = this.getAnnot(event.target.page, "PASTE COMMENT NAME HERE");

a.hidden = !a.hidden;

 

That's it. After you do that each time you click the button the highlight will appear or disappear.

 

Votes

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 ,
Apr 20, 2021 Apr 20, 2021

Copy link to clipboard

Copied

Genius!  Thank you so much!

Votes

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 ,
Apr 21, 2021 Apr 21, 2021

Copy link to clipboard

Copied

So here is another one for you!

 

I want a text box to become visible when they click on a checkbox.  The check should show up and text should show up on another portion of the form.  I have tried the Show/Hide Field, but it doesn't work.  What kind of script can I write to accomplish this?  I can find out what the text is "named" fine.

Votes

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 ,
Apr 21, 2021 Apr 21, 2021

Copy link to clipboard

Copied

You can use something like this as the custom calculation script of the text field:

 

event.target.display = (this.getField("CheckBox1").valueAsString=="Off") ? display.hidden : display.visible;

 

Replace "CheckBox1" with the actual name of your check-box field.

Votes

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 ,
Apr 21, 2021 Apr 21, 2021

Copy link to clipboard

Copied

Yeah!  Thank you again!  That worked perfectly!

Votes

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 ,
May 07, 2021 May 07, 2021

Copy link to clipboard

Copied

Okay, so it works perfectly in Adobe Acrobat Pro DC but when I open the form in just Adobe Reader on my tablet it does not work?  I think I'm going crazy!

Votes

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 ,
May 07, 2021 May 07, 2021

Copy link to clipboard

Copied

You're not. Unfortunately, almost no scripts will work on mobile devices.

If you're using an iOS device try it in PDF Expert by Readdle. If you're on an Android device try the XODO PDF Reader. Those apps have the best chances of it working.

Votes

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 ,
May 07, 2021 May 07, 2021

Copy link to clipboard

Copied

Well that stinks, didn't work with the other apps either.  Can you think of any other way to accomplish this task?

Votes

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 ,
May 07, 2021 May 07, 2021

Copy link to clipboard

Copied

Since you mentioned that it's OK to use an underline you can try the following:

Create just a button over the word and set it as having a transparent fill color, a black border color, and an underline border style. Then add this code as its Mouse Up script:

 

event.target.lineWidth = (event.target.lineWidth==0) ? 1 : 0;

 

Hopefully that will work in one of those apps (I haven't tested it in them, though).

Votes

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
New Here ,
Jul 27, 2022 Jul 27, 2022

Copy link to clipboard

Copied

Despite your detailed instructions, I, as a layman, did not succeed in integrating the function. Apparently I make a mistake already at the beginning and make a wrong Highlight Comment and/or a wrong button. In any case, the Java Console always returns me an error message, such as "Reference Error Button is not defined". Is there a tutorial video or a more detailed step by step description? Thanks for your help!

Translated with www.DeepL.com/Translator (free version)

Bildschirmfoto 2022-07-27 um 17.16.05.png

Votes

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 ,
Jul 28, 2022 Jul 28, 2022

Copy link to clipboard

Copied

LATEST

This command line only works for a selected annot, not for buttons...

@+

Votes

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