How to view PDF files online in Javaweb project

Source: Internet
Author: User

Recently there is a need to implement a direct view of the Pdf,word,excel file on the Web page. But in fact there is no good open source plug-in for us to use, there are some paid plug-in good, but also very useful, but for me is not suitable.

Now it's just a simple way to find the Pentangeli.

is to implement the display of the PDF file, and other files to be converted to PDF in other ways. Although this method is really bad, but there is no way to do, if the future can have a better, then publish something else.

Here I will directly introduce the PDF display method.

Directly on the dry goods.

First copy the following file under the E:\tomcat8\webapps directory

Http://yunpan.cn/cwmjKF6jKY6Kb  access Password c14a
Just like this.

Then open tomcat

Then the browser accesses http://localhost:8080/generic/web/viewer.html

See if a PDF plugin appears

Then open the Generic/web/viewer.js file with Notepad

Modified to var default_url = ';

Then you give a link to any of the items http://localhost:8080/generic/web/viewer.html?file=http://localhost:8080/resources/spring.pdf

Just give one behind the http://localhost:8080/generic/web/viewer.html? File= back with the address of the PDF file you need to access, open such a link can be directly in the page to write the PDF file.

It is important to note that the browser must support HTML5

Incidentally, this is an open source plug-in, Firefox comes with it, so Firefox opens the PDF without this is also possible, but IE will not. So this plugin is needed. This plugin is still very good, very easy to get started, coupling is not high, there is no bug.

Ideas and resources from the following two posts, thank the great God.

Http://www.cnblogs.com/kagome2014/archive/2015/05/26/kagome2014001.html

Http://www.cnblogs.com/studyzy/p/5338398.html

How to view PDF files online in Javaweb project

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.