简体   繁体   English

离线使用PDF.js

[英]Use PDF.js offline

Is it possible to use PDF.js without having the website online? 是否可以在没有网站在线的情况下使用PDF.js? I'm trying to do a simple offline website that reads pdf using pdf.js but it won't work without being online. 我正在尝试做一个简单的离线网站,使用pdf.js读取pdf,但如果没有在线,它将无法正常工作。

Anyone could help? 有人可以帮忙吗?

Yes absolutely you can use it offline. 是的,绝对可以离线使用它。 Download the latest version here . 这里下载最新版本。

Now extract the zip file and put it on a server(use xampp/wamp/lamp or any other localhost) because the worker is not enabled for file:// urls. 现在解压缩zip文件并将其放在服务器上(使用xampp / wamp / lamp或任何其他localhost), 因为worker没有启用file:// urls。

To show the pdf files traverse to web/viewer.html from the localhost and it should load its default pdf. 要显示pdf文件从localhost遍历web / viewer.html ,它应加载其默认pdf。

As to the question about how to show your pdf's use: viewer.html?file=relative/path/to/your/pdf 至于如何显示你的pdf使用的问题: viewer.html?file=relative/path/to/your/pdf

Say for example inside the web folder(the one in which viewer.html is there) of your pdf.js you create a directory say named pdfFiles and in it you add a pdf named say mypdf.pdf in it then to display it use: viewer.html?file=pdfFiles/mypdf.pdf and it will display it. 例如,在您的pdf.js的web文件夹(在其中是viewer.html的那个文件夹)中创建一个名为pdfFiles的目录,然后在其中添加一个名为say mypdf.pdf的pdf然后显示它使用: viewer.html?file=pdfFiles/mypdf.pdf ,它将显示它。

Look here for more details on how to dynamically assign PDF file paths to the viewer. 在此处查看有关如何将PDF文件路径动态分配给查看器的更多详细信息。 If you have any other queries let me know. 如果您有任何其他疑问,请告诉我。 I have used pdf.js offline and it works wonderfully on almost all the browsers I know. 我已经离线使用了pdf.js,它几乎适用于我所知道的几乎所有浏览器。

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

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