简体   繁体   English

如何获取pdfJS从URL呈现pdf?

[英]how to get pdfJS to render a pdf from URL?

i am using PDFJS to render PDFs files using their URL after scanning the current page a js snipet return the urls. 在扫描当前页面后,我正在使用PDFJS使用URL呈现PDF文件,js片段返回了URL。 then it passes them to pdfJS. 然后将它们传递给pdfJS。 until now everything works the problem show when the PDF is already open in the browser . 到目前为止,当浏览器中已经打开PDF时,一切都会正常工作。 i take the URL ( * .pdf) and pass it the same way as before the difference is that the file is not downloaded and i have this response. 我采用URL( * .pdf)并通过与以前相同的方式传递它,所不同的是未下载文件且我收到了此响应。

Warning: Unhandled rejection: Unexpected server response (0) while retrieving PDF " http://geekographie.maieul.net/IMG/pdf/progit.fr.pdf ". 警告:未处理的拒绝:检索PDF“ http://geekographie.maieul.net/IMG/pdf/progit.fr.pdf ”时出现意外的服务器响应(0)。

(just for the record i dont have CORS issues). (仅作记录,我没有CORS问题)。

Try this " http://mozilla.github.io/pdf.js/ " 试试这个“ http://mozilla.github.io/pdf.js/

Installation 安装

  1. download and unzip file. 下载并解压缩文件。
  2. put " PDF " file in this folder. 将“ PDF ”文件放在此文件夹中。
  3. config in " viwer.js ", edit var DEFAULT_URL. 在“ viwer.js ”中进行配置,然后编辑VAR DEFAULT_URL。
  4. upload folder to server. 将文件夹上传到服务器。
  5. Have fun! 玩得开心!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM