Skip to main content
February 26, 2025
Question

Need some help with javascript

  • February 26, 2025
  • 1 reply
  • 227 views

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. 

1 reply

PDF Automation Station
Community Expert
Community Expert
February 26, 2025

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.

February 27, 2025

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

PDF Automation Station
Community Expert
Community Expert
February 28, 2025

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