Skip to main content
Participating Frequently
December 20, 2024
Question

Programmatically adding red box around a two digit number

  • December 20, 2024
  • 1 reply
  • 1311 views

I have a pdf document with a graph containing a line of two digit values (17 of them), e.g.,

     74  63  59  72  ...

I have written a program that checks each value against a specified value to determine if the displayed calue is greater than the specified one.  If it is, I need to draw a red box arouund the displayed value to indicate it exceeds the specified one.  If not possible, I need some way to indicate the exceptions, e.g., changing the font color for that displayed value.  VBA, Javascript, or a language suggested by you are all acceptable.

1 reply

PDF Automation Station
Community Expert
Community Expert
December 20, 2024

Are the values in form fields?

Participating Frequently
December 20, 2024

No

PDF Automation Station
Community Expert
Community Expert
December 20, 2024

Use the comment markup "Square" tool and draw a box.  Then, name the annotation by selecting it and running the following script in the console (name example is "Square1"):

this.selectedAnnots[0].name="Square1";

Also, make it "readonly" so that it can't be resized, moved, or deleted by the end user by running the following script in the console:

this.selectedAnnots[0].readOnly=true;

Also, add the display value to it's contents like this:

this.selectedAnnots[0].contents="72";

Hide the annotation by running the following script in the console:

this.selectedAnnots[0].hidden=true;

Change the hidden property of the annotation to true or false in your calculation, calling it by its name like this:

var anot=this.getAnnot(0,"Square1");
if(75>Number(anot.contents))
{anot.hidden=false}
else
{anot.hidden=true}

Note, the 0 before "Square1" is the page index of the annotation (page 1 in this case).