How to use pdf.js, simplified version

Many people are talking about using pdfjs to realize the pdf trial reading function. I didn't study it before, so I took a look today. There are many instructions on the Internet, if not too cumbersome, or not too concise, let's sort it out by yourself today.

Original website address:
http://mozilla.github.io/pdf.js/

1. Download js
Insert picture description here
Insert picture description here
2. After decompression, there are two folders like this
Insert picture description here
3. Create a new pdf file directory and drop these two folders into it. Then, upload it to the project. I put it in js.

Four, use:

<iframe id="previewpdf" src="../js/pdf/web/viewer.html?file="+url+"#page=1" width="100%" frameborder="0"></iframe>

Among them, the url in src is the preview address of the pdf file, and page is set to display from the first page when the pdf is opened.

or:

<a href="../js/pdf/web/viewer.html?file="+url+"#page=1" target="_blank">查看</a>

Guess you like

Origin blog.csdn.net/weixin_42645716/article/details/107188081