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?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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
Karl Heinz KremerCommented:
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.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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...
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Adobe Acrobat

From novice to tech pro — start learning today.