PDF Editing Issues

How to Highlight PDF Text Automatically When Clicking a Bookmark

Jason MillerJason Miller Oct 28, 2026 870 views

Question details

The user wants to configure a PDF bookmark so that clicking it not only navigates to the target page but also dynamically highlights a specific paragraph or sentence.

How to Highlight PDF Text Automatically When Clicking a Bookmark
Product
PDF Editors
Device & OS
not provided
Scenario
Creating interactive PDF documents where navigating via bookmarks automatically draws the reader's attention to specific content using highlights.
Observed behavior
By default, PDF bookmarks only navigate to a specific page or view. They do not highlight or select the specific text the user intends to emphasize upon arrival.
Before you start

Ensure you are using a professional PDF editor that supports running JavaScript actions from bookmarks, such as Adobe Acrobat Pro, as standard PDF readers may not execute bookmark scripts.

Solution 1Recommended

Use JavaScript Actions on Bookmarks to Create Highlight Annotations

Add a custom JavaScript action to your bookmark properties that triggers a highlight annotation over a specific location upon clicking.

You can program a bookmark to execute Acrobat JavaScript. This script can be set up to dynamically create a highlight annotation at specific page coordinates or toggle the visibility of an existing annotation when the bookmark is clicked.

Since this method relies on exact page coordinates, any changes to the document's layout later on might misalign the highlight.

1
Create the target bookmark

Open the PDF editor, navigate to the desired page, and create a new bookmark in the Bookmarks panel on the left.

2
Open bookmark properties

Right-click the newly created bookmark and select 'Properties' from the context menu.

3
Add a JavaScript action

Go to the 'Actions' tab. From the 'Select Action' dropdown menu, choose 'Run a JavaScript' and click the 'Add' button.

4
Enter the custom script

In the JavaScript Editor window, input the code to add a highlight annotation using the addAnnot method. You will need to specify the page number and precise 'rect' coordinates for your text.

5
Save and test

Click 'OK' to save the script. Close the properties dialog and click the bookmark to verify that the highlight appears over the correct text.

Use JavaScript Actions on Bookmarks to Create Highlight Annotations
Coordinate Setup: Finding exact page coordinates (rect bounds) requires careful setup. Always re-test your bookmark's highlight action if you edit, crop, or rearrange pages in the document.
Easy PDF Management

Highlight and Bookmark PDFs Easily with WPS Office

While scripting custom bookmark highlights can be overly complex and prone to coordinate errors, WPS PDF provides intuitive tools to instantly highlight important text and associate them with organized bookmarks. Annotate, edit, and manage PDFs without writing a single line of code.

  1. 1. Open your PDF in WPS Office: Launch WPS Office and open the target PDF file using the WPS PDF viewing tab.
  2. 2. Highlight the text manually: Select the 'Comment' tab, click the 'Highlight' tool, and drag your cursor over the sentence or paragraph you want to emphasize.
  3. 3. Add a bookmark to the highlighted section: Navigate to the highlighted page, open the Bookmarks pane on the left sidebar, and click the '+' icon to create a new bookmark pointing directly to this page.
Easily highlight text, paragraphs, or specific areas with a single click.Create, rename, and organize bookmarks without complex JavaScript scripting.Fully compatible with standard Adobe PDF formats and external PDF viewers.Lightweight, fast, and accessible across Windows, Mac, and mobile platforms.
microsoft office alternative - wps office

Frequently Asked Questions

Can standard PDF readers execute dynamic bookmark highlights?

Most basic PDF readers cannot execute JavaScript actions attached to bookmarks. To ensure the highlight script runs properly, users typically need to open the document in a fully-featured PDF editor like Adobe Acrobat.

Will the highlight remain accurate if I add new pages to the PDF?

If you use JavaScript to specify page coordinates, adding or rearranging pages may misalign the highlight or place it on the wrong page entirely. You will need to update the script's page parameters if the document layout changes.

Is there an easier way to highlight text on bookmark click without coding?

Without using JavaScript, the standard and most reliable approach is to manually apply a highlight annotation to the text in the document beforehand, and then set a standard bookmark to navigate directly to that specific page or zoomed view.