I work for a scientific publisher and I'm trying to create a custom search menu command in Acrobat using Javascript. I want to be able to search for multiple terms (aux electronic suppl supporting online repository dynamic content appendix appendices) at once just by clicking on a menu command. I don't have any experience coding in Javascript, but I managed to cobble some code together.
Here is what I have so far:
function auxmatSearch(){
app.alert("Aux Mat Keyword Search:" + this.cQuery);
}
search.matchCase = false;
search.wordMatching = MatchAnyWord;
search.bookmarks = false;
search.query("aux electronic suppl supporting online repository dynamic content appendix appendices","ActiveDoc");
app.addMenuItem ({cName: "Aux Mat Search", cParent: "Tools", cExec: "auxmatSearch()"
});
I know some of the code is wrong since the command doesn't appear in Acrobat's menu, but I don't know what part is wrong or if I'm missing some code. I searched for similar examples of custom search scripts but couldn't find any. I'm stuck at the moment. Does anyone have any suggestions?
Secondly, all of your search commands should be inside the function.
Thirdly, you need to place MatchAnyWord inside double-quotes, since it's a string.
But the most important thing is that your alert will not show anything. The search object is used to launch the built-in search window of Acrobat. It doesn't return any values.
You can use something like this (in a folder-level script):
function auxmatSearch(){
search.matchCase = false;
search.wordMatching = "MatchAnyWord";
search.bookmarks = false;
search.query("aux electronic suppl supporting online repository dynamic content appendix appendices","ActiveDoc");
}
app.addMenuItem ({cName: "Aux Mat Search", cParent: "Tools", cExec: "auxmatSearch()"});
- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com