Skip to main content
Participant
January 21, 2025
Answered

Circle text based on Text box contents

  • January 21, 2025
  • 3 replies
  • 1047 views

Hi all - I'm using Adobe Acrobat Pro.  I have a form (not designed by me) that to complete, the user would fill in a number in a text box, and based on the number, certain values on the form would be circled.  Example: if 50 were filled in to the text box, certain information on the page would be circled.  If 55 were filled in to the text box, other informatikon on the page would be circled.  Is there a way to have a hidden circles around each section of information and then have cirtain circles appear based on the number filled in to the text box?

Correct answer Nesa Nurani

If you need to 'circle' around specific info, like part of the text on the page, you can use a text field to do it.

Create a New Text Field:
  Name the text field (e.g., "Circle1").

Set Field Properties:
  General Tab:
  Set the field to Hidden and Read-Only.

Appearance Tab:
  Choose your desired border color to act as the "circle".
  Set the fill color to "None" (transparent).

Position the Field:
  Place the newly created text field over the information you wish to "circle" on the page.

Add Validation script:
  Go to the field where you enter numbers.
  Under the Validate tab, choose "Run custom validation script" and enter the following code:

this.getField("Circle1").display = (Number(event.value) == 50) ? display.visible : display.hidden;

This script will make the "Circle1" field visible when the entered value is 50. Otherwise, it will remain hidden.

 

Adding Additional "Circles":

 To circle multiple areas based on different conditions:
 Create additional text fields (e.g., "Circle2", "Circle3", etc.).
 Use the same script but update the field name and condition for each:

this.getField("Circle2").display = (Number(event.value) == 75) ? display.visible : display.hidden;
this.getField("Circle3").display = (Number(event.value) == 100) ? display.visible : display.hidden;

Notes:

Replace 50, 75, and 100 with the specific numbers for which you want each "circle" to appear.
Adjust the size and position of each "circle" (text field) as needed to align with the target text or information on the page.

3 replies

Nesa Nurani
Community Expert
Nesa NuraniCommunity ExpertCorrect answer
Community Expert
January 22, 2025

If you need to 'circle' around specific info, like part of the text on the page, you can use a text field to do it.

Create a New Text Field:
  Name the text field (e.g., "Circle1").

Set Field Properties:
  General Tab:
  Set the field to Hidden and Read-Only.

Appearance Tab:
  Choose your desired border color to act as the "circle".
  Set the fill color to "None" (transparent).

Position the Field:
  Place the newly created text field over the information you wish to "circle" on the page.

Add Validation script:
  Go to the field where you enter numbers.
  Under the Validate tab, choose "Run custom validation script" and enter the following code:

this.getField("Circle1").display = (Number(event.value) == 50) ? display.visible : display.hidden;

This script will make the "Circle1" field visible when the entered value is 50. Otherwise, it will remain hidden.

 

Adding Additional "Circles":

 To circle multiple areas based on different conditions:
 Create additional text fields (e.g., "Circle2", "Circle3", etc.).
 Use the same script but update the field name and condition for each:

this.getField("Circle2").display = (Number(event.value) == 75) ? display.visible : display.hidden;
this.getField("Circle3").display = (Number(event.value) == 100) ? display.visible : display.hidden;

Notes:

Replace 50, 75, and 100 with the specific numbers for which you want each "circle" to appear.
Adjust the size and position of each "circle" (text field) as needed to align with the target text or information on the page.

Participant
January 22, 2025

This worked perfectly, thank you!

PDF Automation Station
Community Expert
Community Expert
January 22, 2025

This article walks you through it in the Circle-The-Answer Theme section:

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

Thom Parker
Community Expert
Community Expert
January 21, 2025

Yes, in fact, JS code can create circles.  However, this type of action will only work in compliant PDF viewers. It won't work in a browser or mobile device. 

 

Use the regular Markup annotations to make the circle.

The annotations all have a "hidden" property that can be set from a script. 

https://opensource.adobe.com/dc-acrobat-sdk-docs/library/jsapiref/JS_API_AcroJS.html#hidden

 

To get the annot you'll need to do one of two things. Write code to search the annots on a page for the one you want, or name the annot.  There is no UI for setting an annotation name, it has to be done from the console window. 

 

 

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
Thom Parker
Community Expert
Community Expert
January 22, 2025

Another option is to use a radio button field as the circle.  Make the fill transparent and set ReadOnly to true, so it's just a graphic. 

 

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often