Skip to main content
Participant
May 15, 2017
Question

Find and replace pages with part of a url

  • May 15, 2017
  • 1 reply
  • 333 views

I've made a pdf of our colleges previous course catalog and for some reason it added links to pages outside of the path for the catalog. I need to search for pages that contain part of the url "/news" and delete them from the pdf. I've tried using a javascript, but nothing in the document is ever removed.

This is what I tried:

for (var p=this.numPages-1; p>=0; p--) {

    for (var n=0; n<this.getPageNumWords(p); n++) {

        if (this.getPageNthWord(p, n) == "/news") {

            this.deletePages(p);

            break;

        }

    }

}

This topic has been closed for replies.

1 reply

try67
Community Expert
Community Expert
May 15, 2017

I suggest you write a script that prints each word in a page to the console

and see what the output is... It might not be what you expect it to be.

On Mon, May 15, 2017 at 5:27 PM, stevevoltmer <forums_noreply@adobe.com>

Participant
May 15, 2017

Okay, I just did and it finds "news", but doesn't include "/news". Is there anyway to include the "/" in the word search?

try67
Community Expert
Community Expert
May 15, 2017

You need to set the third parameter of getPageNthWord as false to do that. It will likely be a part of the previous word, though, or appear as its own word.