Pdf.js Using Tutorials

Source: Internet
Author: User

Pdf.js framework of the charm, for its implementation for the HTML5, without any local support, and browser compatibility is also better, requires only one: Browser support HTML5! (But for the lower version of IE, you can only my condolences!) )

It is said that IE9 above is OK, because my local is IE11, so I only tested on the IE11, is through (of course, Firefox, 360, I also measured, is OK).

Because the project development needs, online display PDF, and to be compatible with IE, so chose Pdf.js, but the online tutorial on his few, I took a day to fix, looked back a bit, also did not imagine so difficult, so decided to write a blog, so that everyone reference!

The following are the Pdf.js related URLs:

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

Above this site, have pdf.js basic introduction, and how to get the source code, then how to build!

But his access to the source code uses:

$ git clone git://github.com/mozilla/pdf.js.git

Build using:

$ node Make generic

I do not know how to use git, node on Windows7 (if you know, you can tell me, thank you here!). , so I switched to Linux to build (during a lot of sad course, feel can be made into a movie!!!) For example, I use Git to get the source code, the system prompts me git does not install, I use node, prompt me Shelljs not install, install Shelljs, he told me to use NPM, unsurprisingly, NPM I did not install ... In fact, we use pdf.js, ultimately only need to build the content, you can download here:

http://yunpan.cn/cwmjkf6jky6kb  access password c14a

The constructed directory structure is:

With the built-in build content, we can do a simple test to copy the generic into Tomcat's WebApps

After you start Tomcat, you can go through:

http://localhost:8080/generic/web/viewer.html

To visit! Can see a very handsome interface:

Generic/web/viewer.html is mainly about rendering the PDF reader, while Generic/web/viewer.js is specifying the open PDF file (and of course there are other features that are not our concern), and we look at the generic/ Web/viewer.js section of code:

As we can see, he opens the Generic/web/compressed.tracemonkey-pldi-09.pdf file by default and looks at the following code:

This tells us that you can dynamically specify an open PDF file by passing the file parameter! Such as:

http://localhost:8080/generic/web/viewer.html?file=qbs.pdf

Below I introduce, the concrete embed project is how to use!

The content in generic can be used as a third-party plug-in, which can be stored in the project as follows:

The page can then use the <iframe> tab to load the PDF

1 <iframe src= "<c:url value="/resources/plugin/pdfjs/generic/web/viewer.html "/>?file=<c:url Value= "/publicity/displaypdf. do "/>" width= "100%" height= "></iframe>"

As follows:

The essence is that we directly access the generic/web/viewer.html and then assign it a file parameter that specifies the open PDF file! I use the flow above to specify the way.

At this point, the introduction of Pdf.js plug-in is over, the first time to write a blog, if there is no place, I hope you can advise, thank you!

Thanks to Pdf.js's two authors here! (sincerely admire these foreign masters, 2 people can write a good framework, but also open-source!) )。

Thank you, Mr. Hyhbyl! His article has guided me! One copy of the attached website:

http://blog.csdn.net/hyhbyl/article/details/20994945

Pdf.js Using Tutorials

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.