How to Find, Highlight, and Add Notes to Text in Acrobat using JavaScript
Question details
The user needs an automated way to search for a specific word or phrase in a PDF, highlight every occurrence, and append the exact same explanatory note or definition to each instance.

- Product
- Adobe Acrobat
- Device & OS
- not provided
- Scenario
- Reviewing or annotating a PDF document where a recurring term requires a standard definition or comment applied to every instance automatically.
- Observed behavior
- Manual highlighting and commenting is too slow, so the user is looking for a JavaScript solution or Action Wizard workflow to automate the repetitive task across long documents.
Ensure you are using Adobe Acrobat Pro DC, as the Action Wizard and the ability to execute advanced batch processing JavaScripts are not supported in the free Adobe Acrobat Reader.
Use Action Wizard and Custom JavaScript in Acrobat Pro DC
Automate the highlighting and note-adding process by combining Acrobat's built-in Action Wizard with a custom JavaScript routine.
While Adobe Acrobat does not have a native one-click button to simultaneously highlight and add specific notes to all matching text across a whole document, you can achieve this by creating an Action Wizard workflow.
This method is highly efficient for long documents. It requires you to insert a custom script designed to loop through the document's words, match your target text, and apply a highlight annotation that contains your desired note text.
Launch Adobe Acrobat Pro DC, navigate to the Tools menu, and select Action Wizard.
Click on 'New Action'. Under 'Choose tools to add', select 'More Tools' and then add 'Execute JavaScript' to the action steps on the right panel.
Click 'Specify Settings' on the Execute JavaScript step. Paste your custom JavaScript code that defines the target search phrase and uses the addAnnot method to create a highlight with the 'contents' property set to your explanatory note.
Uncheck 'Prompt User', save the action with a descriptive name, and run it on your target PDF document to apply the highlights and notes instantly.

Install a Specialized Third-Party Script or Tool
Utilize pre-built custom tools or plugins if you are not comfortable writing and debugging JavaScript from scratch.
Search, Highlight, and Annotate PDFs with WPS Office
If you do not want to deal with complex JavaScript coding, WPS Office offers a highly intuitive PDF editor. It provides a user-friendly interface to quickly search for text, apply highlights, and add comments to your PDFs effortlessly, making it an excellent alternative for comprehensive document management.
- 1. Open your PDF in WPS Office: Launch WPS Office and open the PDF document you need to review and annotate.
- 2. Search for your text: Press Ctrl+F (or Cmd+F on Mac) to open the search bar and locate the word or phrase you want to define.
- 3. Highlight and Comment: Navigate to the Comment tab, select the Highlight tool to mark the found text, and then double-click the highlight to attach your explanatory note.

Frequently Asked Questions
Can I use standard Adobe Acrobat Reader to run these JavaScript Actions?
No, the Action Wizard and the ability to execute advanced batch processing scripts are exclusive features of Adobe Acrobat Pro DC. The free Reader version does not support these automated workflows.
How do I access the JavaScript console to test my script in Acrobat?
You can open the JavaScript debugger in Adobe Acrobat by pressing Ctrl+J on Windows or Cmd+J on Mac. This allows you to test and troubleshoot your code before embedding it into an Action Wizard workflow.
What happens if my target word is part of a larger word?
If you use a basic search script, it might highlight partial matches (e.g., finding 'cat' inside 'category'). To prevent this, your custom JavaScript must use Regular Expressions (Regex) configured to match whole words only.
Is there a built-in button to highlight all instances in Acrobat without scripting?
No. While Acrobat's advanced search can find all instances of a word, it does not natively possess a single button to simultaneously apply highlights and identical explanatory notes to all those instances without the use of custom JavaScript or third-party plugins.




