Use drop down list to search pdf

Is there a way to create a drop-down list that can be used to search a pdf document? I'd like to have the user select an item from a drop down and then have the document scroll or go to the place in the document that matches the item selected. Is that possible?


Wayne Sexton


2 Answers

Do you want the drop-down to actually perform a search, or do you just want to link each item to a specific location in the file? Both are possible, but the first one is more complex to implement.

.


Visit my custom-made PDF scripts website: http://try67.blogspot.com

Contact me personally: try6767@gmail.com


Gilad D (try67)   

This is something you can start from:

// Define Regular Expression for search
var rgExp = new RegExp(event.value);
// Matches Soc. Sec. Num.
// Loop over document pages
var foundAtPag = [];
for(var pg=0; pg<this.numPages; pg++) {
    var len = getPageNumWords(pg); 
    // Loop over words on page
    for(var i=0; i<len; i++) {
        var wd = this.getPageNthWord(pg, i, false);
        if(rgExp.test(wd)) {
            foundAtPag.push(pg);
            this.addAnnot({
                            page: pg,
                            strokeColor: color.yellow,
                            type: "Highlight",
                            quads: this.getPageNthWordQuads(pg, i),
                            });
        }
    }
}
var gotoPag = foundAtPag[0];
this.pageNum = gotoPag;

credits: http://acrobatusers.com/tutorials/auto_redaction_with_javascript

I put the code into the Combobox | Validation custom script. First set Combobox Options property "Immediately set value".

It searches for words listed in the Combobox, highlights all of them and moves the document view to the first one.

Then, you can manually remove annotation marks from the Comments pane of the tool bar. Otherwise, you should script a button to have it done at mouse-click.

Hope it helps.


Ricardo Falegnami   


Please specify a reason: