Mohammad Ali Akbari
Mohammad Ali Akbari

Reputation: 10395

Pass pdf url to pdf.js in query string

I'm new to node/pdf js. I just install node and run pdf.js.

Now I want know how can I open pdf files using pdf js by passing pdf file url as parameter in query string?

Upvotes: 1

Views: 9302

Answers (3)

nic
nic

Reputation: 39

On a further note, it is important to know that the file=document.pdf argument must come before the hash sign:

http://myserver.com/web/viewer.html?file=test.pdf#page=6&zoom=page-fit,0,540

HTH

Upvotes: 0

async5
async5

Reputation: 2691

Try adding ?file=document.pdf to the viewer url. See also https://github.com/mozilla/pdf.js/issues/2496

Upvotes: 4

Kristof Mols
Kristof Mols

Reputation: 3557

It will require some changes in the viewer.js:

  • Move parseQueryString: function pdfViewParseQueryString(query) outside var PDFView so it's a standalone function: function pdfViewParseQueryString(query)
  • Replace all occurences of PDFView.parseQueryString(..) to pdfViewParseQueryString(..)
  • Change var DEFAULT_URL = '' to var urlParm = pdfViewParseQueryString(document.location.search.substring(1)); var DEFAULT_URL = urlParm.url;
  • You should now be able to call the viewer with somethin like $("actualViewer").src = 'pdfViewer?url=' + encodeURIComponent(pathToFile);

Upvotes: 1

Related Questions