how to implement pdf.js to view pdf files in the pdf viewer?

删除回忆录丶 提交于 2019-12-23 04:57:18

问题


i want to open pdf files that are linked to in a document in a new page in the pdf.js viewer.

i have downloaded the zip file from github:

https://github.com/mozilla/pdf.js

and gone to both of the index.html files in the examples folder.

i get blank pages when opening either of these files.

can anyone please tell me how to implement pdf.js so that i can open pdf documents in a new page in the pdf viewer?

thank you.


回答1:


Try using '?file=url' in query-string with viewer.html.
For example: www.example.com/pdf-js/web/viewer.html?File="URL"

Source: pdf-js on github

And yes, you will most definitely have cross-domain issues if not using any web-server, as mentioned by @Silent.

Cheers.




回答2:


Let me guess that you tried to directly open the examples via chrome. Your url probably starts off with file:///. This is causing a cross origin request error to occur on your browser. To properly view the examples, you need a LAMP stack.



来源:https://stackoverflow.com/questions/14917749/how-to-implement-pdf-js-to-view-pdf-files-in-the-pdf-viewer

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!