Access pdf.js objects

199 views
Skip to first unread message

Andrew MacFie

unread,
May 18, 2015, 2:18:13 PM5/18/15
to penta...@googlegroups.com
If I open a PDF in firefox, the F12 console indicates that there is a global variable named `PDFViewerApplication` with, e.g. `PDFViewerApplication.page` which is the current page number. How can I access this object from Pentadactyl? In the `:js` REPL, the property `content.window.PDFViewerApplication`  is undefined.

Kris Maglione

unread,
May 18, 2015, 3:13:01 PM5/18/15
to penta...@googlegroups.com
You need to use `content.wrappedJSObject`


--
Kris Maglione

On two occasions I have been asked, "Pray, Mr. Babbage, if you put
into the machine wrong figures, will the right answers come out?" I am
not able rightly to apprehend the kind of confusion of ideas that
could provoke such a question.
--Charles Babbage

Andrew MacFie

unread,
May 18, 2015, 10:17:40 PM5/18/15
to penta...@googlegroups.com
Thanks:)

If anyone's interested, here's a little command for jumping to a specific page in a PDF:

" jump to page in pdf
command! -nargs=1 pdfseek -js <<EOF
  if (!args) {
    args = 1;
  }
  if (content.wrappedJSObject.PDFViewerApplication) {
    content.wrappedJSObject.PDFViewerApplication.page = +args;
  }
EOF
Reply all
Reply to author
Forward
0 new messages