1

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?

3 Answers 3

4

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

Sign up to request clarification or add additional context in comments.

Comments

1

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);

Comments

0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.