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.
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
...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.
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?
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.
Copy link to clipboard
Copied
Genius! Thank you so much!
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.
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.
Copy link to clipboard
Copied
Yeah! Thank you again! That worked perfectly!
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!
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.
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?
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).
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)
Copy link to clipboard
Copied
This command line only works for a selected annot, not for buttons...
@+