Forum moved here!

Home / Command Line - How to Goto bookmark or Find text by named destination

q1w2e

It would be great if a calling program could specify from the command line a jump to a bookmark with the name, similar to moving to a page with the specified number

sumatraPdf.exe test.pdf -bookmark Bookmark1
or
sumatraPdf.exe test.pdf -bookmark "My Bookmark"

GitHubRulesOK

@q1w2e

Similar to acrobat these are called “named” destinations,

you will find that option along with others under the heading "Navigation options"
on the folowing page https://www.sumatrapdfreader.org/docs/Command-line-arguments.html
so for your example it would be

“SumatraPdf.exe” -named-dest “My Bookmark” “test.pdf”

beware you MAY need all the quote marks as shown for filepath / strings wih spaces

note the bookmark MUST usually :slight_smile: be a full bookmark entry including spaces as shown, however there are a few cases where that may not apply, just to trip you up :slight_smile:

ALSO note that the results may NOT always be what you expect, often the page expected is shown but the highlighted entry may not be the one you entered, this is quite common due to overlapping or mis-sychronised / nested Bookmarks, it is better to use the -page ( and -scroll) option rather than bookmarks unless they are very well formed and tested

q1w2e

Thank you very much for clarification

Fim

Can I search a particular word in a pdf file from the command-line, ie the same com Ctrl-f ?
/Fim

mark1212

Hi, great app.
I read the command line arguments page and is there simply a way to do a text search from the command line?
Thanks,
Mark

SumatraPeter

Not sure whether he’s changed his mind in the last 5 years, but here’s the dev’s response:

GitHubRulesOK

I have uploaded my script that adds such use it is available to view here

And you can download from https://github.com/GitHubRulesOK/MyNotes/raw/master/AppNotes/SumatraPDF/LookInClass.cmd (beware the name may change) but name it “anything you like.cmd” NOT .TXT

Try it out so -find must be first choice ( or only choice) it will only find the first match after the point of entry so that could be the start of file or a given page or a named image location in a folder (It can go there but nothing to “find”:slight_smile: )
I does not work with PostScript files or HTTP type filenames as they are converted to local names so best to download then -search in the local files.

myFinder.cmd -find “Magic Mike” -page=20 example.pdf

Most likely results in a cryptic message, “The system cannot find the batch label specified - bummer”

What that really needs to show is that example.pdf was not found or badly specified
Let me know if it helps and I may tidy it up based on your testing

Things to try : the find option can be abbreviated to

-f "a multi word spaced out string"

the more unique it is the less likely to be found earlier than wanted however much more likely to NOT make a match without breaks.
Sometimes case can shift about without reason here I clearly asked for a phrase using Caps and lower case (not that it matters, there should be NO case difference in actions)
Lookinclass.cmd -f “Example Bibliography” F:\Data\Samples\epub\booksample.epub
The destination is shown that way but the sendkeys has decided to switch to upper case halfway through ! but on a second run does not ! ! (sendkeys is notorious for many odd effects)