Skip to main content
Participating Frequently
Dec 20, 2024 7:34 PM UTC
Question

Programmatically adding red box around a two digit number

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.

21 replies

PDF Automation Station
Community Expert
Community Expert
Dec 20, 2024 9:32 PM UTC

Are the values in form fields?

Translate
Participating Frequently
Dec 20, 2024 9:50 PM UTC

No

Translate
PDF Automation Station
Community Expert
Community Expert
Dec 20, 2024 10:12 PM UTC

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).

Translate