Skip to main content
Feb 26, 2025 8:52 PM UTC
Question

Need some help with javascript

I have a word search puzzle in PDF format that I need to make interactive. The only thing so far that seems to work is adding buttons to each letter. My thought is once the user finds the word they can select each letter (button) to spell out the word. 

 

My dilemma is that I need the colors of each button to be transparent enough for the letters to show through. Plus I would like for the colors to toggle between a blue (selected), green (correct) and transparent (starting point). I saw a previous post about javascript for buttons changing colors, but the colors weren't light enough for my letters to show through. 

3 replies

PDF Automation Station
Community Expert
Community Expert
Feb 26, 2025 9:29 PM UTC

It doesn't matter how light the colors are.  The field fill is either transparent or a color.  If it is a color, nothing will show through.  Annotation markups have transparency functionality.  You could use those and overlay a transparent button to control the color.

Translate
Feb 27, 2025 11:21 PM UTC

Okay and thanks but what would the javascript look like for that with the annotation markups?

Translate
PDF Automation Station
Community Expert
Community Expert
Feb 28, 2025 12:23 AM UTC

The easiest way is to name them, and then change the fill color like this:

this.getAnnot(0, "Square1").fillColor=color.red;

The script above changes the fill color of an annotation named "Square1" on page 1 to red.  The following article, in the Circle-The-Answer section, explains how to name annotations (because they are given random names when created with the User Interface):

https://pdfautomationstation.substack.com/p/coverting-disobliging-pdfs-into-fillable

 

Translate