Search PDF for list of words and Create a Bookmark with Javascript

I have a list of about 200 different strings.  I have a large PDF file (about 1600 pages).  I'm looking for a java script that will search the document for each of these strings and when it gets a match I need it to create a bookmark, I'm running Acrobat X Pro.  

I'm not that familliar with Java Script but I can understand it.  If you could help me with different elements that would be helpful.

need to know how to bring the strings into the script and loop through them, also need to know how to search for them and then to create the bookmark.  

Not an easy task for me. I'm new to the PDF development community. Thanks,

Who is Participating?
Karl Heinz KremerConnect With a Mentor Commented:
mplungian is wrong, this can be done in JavaScript, but it will not be easy.

Searching in a PDF file using JavaScript is not straight forward, and this meay be the deal breaker for you. You cannot search using JavaScript. What you can do is to enumerate all "words" on a PDF page, and then you can try to match these words with your search strings.

So let's say your first search string is "The new location". You would then use the JavaScript "word finder" interface to iterate over all words:

var cnt=0;
for (var p = 0; p < this.numPages; p++) {
    var n = getPageNumWords(p);
    for (i=0; i<n; i++) {
        console.println("Word #" + i + " = " this.getPageNthWord(p, i));

Open in new window

You need to come up with reliable code to iterate over the words in your search terms and the words in your document to find matches. This is not a simple task, and you would probably need quite a bit of JavaScript experience to get this working.

Once you have the search terms, you can get the "quads" (the location and size) of the words in your matched search term, and then create the bookmark to that page.
Michel PlungjanIT ExpertCommented:
I do not believe there is an API to the PDF internals accessible to client side JavaScript

Perhaps Visual Basic for Applications is what you are looking for.

You can add JavaScripts to the PDF itself, but I doubt it can generate a bookmark.

Another place to ask this question is
joshcallahan1Author Commented:
I have created bookmarks with java script using PDF Batch processing with Acrobat X pro
Michel PlungjanIT ExpertCommented:
" wrong" - only on my doubt that embedded JS could create bookmarks

You are referring to embedded javascript inside the pdf.
Not in a script on the HTML page where the pdf id embedded...
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.