• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Can the latest version of Adobe Acrobat Pro Find and Replace Bookmark Text

New Here ,
Mar 15, 2023 Mar 15, 2023

Copy link to clipboard

Copied

Trying to Find and Replace text within "Bookmarks Only". Using Ctrl+F, one can Find text and include Bookmarks. Once Find and Replace is selected, Include Bookmarks gets greyed out (see att.). If seen Add-ons do this in the past, but the current Acrobat doesn't have this functionality.

TOPICS
Edit and convert PDFs , How to

Views

1.3K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
1 ACCEPTED SOLUTION
Community Expert ,
Mar 15, 2023 Mar 15, 2023

Copy link to clipboard

Copied

May be possible with a script. 

View solution in original post

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 15, 2023 Mar 15, 2023

Copy link to clipboard

Copied

May be possible with a script. 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 15, 2023 Mar 15, 2023

Copy link to clipboard

Copied

As mentioned, this is only possible using a script, like this (paid-for) tool I've developed:

https://www.try67.com/tool/acrobat-search-replace-text-in-bookmarks

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 30, 2024 May 30, 2024

Copy link to clipboard

Copied

I just asked Copilot to create a script for me. It worked! Here's the script it generated and instructions for adding it as an icon to your toolbar! The function will also delete text from bookmarks if you leave the Replace Text user input blank.

 

// Define the search and replace function
function searchAndReplaceInBookmarks() {
    // Prompt the user to input the old text
    var searchText = app.response({
        cQuestion: "Please enter the text you want to search for:",
        cTitle: "Search Text"
    });

    // Prompt the user to input the new text
    var replaceText = app.response({
        cQuestion: "Please enter the replacement text (leave blank to delete the search text):",
        cTitle: "Replace Text"
    });

    // Get the root bookmark item
    var rootBookmark = this.bookmarkRoot;

    // Call the recursive function to search and replace text
    searchAndReplaceInBookmarkItem(rootBookmark, searchText, replaceText);
}

// Recursive function to search and replace text in each bookmark item
function searchAndReplaceInBookmarkItem(bookmarkItem, searchText, replaceText) {
    // Check if the bookmark item has children
    if (bookmarkItem.children != null) {
        for (var i = 0; i < bookmarkItem.children.length; i++) {
            // Recursive call for each child bookmark item
            searchAndReplaceInBookmarkItem(bookmarkItem.children[i], searchText, replaceText);
        }
    }

    // Check if the bookmark item's name contains the search text
    if (bookmarkItem.name.indexOf(searchText) != -1) {
        // If replace text is not provided, delete the search text
        if (replaceText === "") {
            bookmarkItem.name = bookmarkItem.name.replace(searchText, "");
        } else {
            // Replace the search text with the replace text
            bookmarkItem.name = bookmarkItem.name.replace(searchText, replaceText);
        }
    }
}

// Call the function when the document is opened
searchAndReplaceInBookmarks();

 

This script will now check if the replaceText is empty and if so, it will remove the searchText from the bookmark names. If replaceText is provided, it will replace the searchText as before. Remember to save your document before running the script to prevent any unintended changes. If you have any more questions or need further modifications, feel free to ask!

 

 

To add a shortcut icon to your document toolbar in Adobe Acrobat Pro for the script, you'll need to create an Action with the Action Wizard and then add this Action to the Quick Tools Toolbar. Here's how you can do it:

 

  1. Open the PDF document in Adobe Acrobat Pro.
  2. Go to the "Tools" menu and select "Action Wizard."
  3. Click "Create New Action."
  4. Start with a blank action, and then click "More Tools" from the "Choose tools to add" panel.
  5. Scroll down and select "Execute JavaScript," then click the "Add" button.
  6. Click on "Specify Settings" and paste the updated JavaScript code into the provided field.
  7. Click "Save" and give your action a name (e.g., "SearchReplaceBookmarks").
  8. Click "Save" again to finish creating the action.
  9. Now, go to the "Tools" menu and select "Customize Quick Tools Toolbar."
  10. Under the "Choose tools to add to the toolbar" section, select "Action Wizard."
  11. Find the action you just created (e.g., "SearchReplaceBookmarks") and click the "Add to Toolbar" button.
  12. You can also assign an icon to this action by clicking on the "Edit" button next to it.
  13. Once you've added the action to the toolbar and chosen an icon, click "Save."

 

Now you will have a shortcut icon on your Quick Tools Toolbar that will run the script when clicked. Remember to save your document after making these changes. If you need any further assistance or clarification, please let me know!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 20, 2024 Dec 20, 2024

Copy link to clipboard

Copied

Thanks, very useful.

There is however one aspect that I would need to improve.

The script launched with an action on multiple documents proposes the search/replace window for each document.

Is it possible to modify the script so that the insertion of the text to search/replace is asked only once (not once for each document) and the replacement is applied to all documents?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 20, 2024 Dec 20, 2024

Copy link to clipboard

Copied

LATEST

In order to do that you would need to save the user input into global variables and then change the code to use them if they exist, and if not, prompt the user to enter them. That way they will be prompted for the first file, and the ones after it will be processed automatically.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines