The simple mobile side opens the PDF file.

Source: Internet
Author: User
Tags pdf parser

Business needs, in doing a medical product type of project. Most of them are a series of treatment solutions for medical devices. Recent product requirements need to add a PDF type of product instruction details to each product model.

Simply put, in the product this table with a field to store the PDF file, the user at the end of the scan QR code can view the contents of this PDF file. This is the need, followed by a concrete implementation:

This thing was not touched before, only know a lot of applications have a PDF parser, such as QQ. QQ parsing PDF file style is very good-looking, but there is no way to find the category of QQ analytic PDF method, the most used in online search is to use Pdf.js to parse .

First go to official Internet download PDFJS. I downloaded the address: Http://mozilla.github.io/pdf.js/,pdf's demo must be open in a Web project, so you must deploy the Web project.

After downloading, put it under the WebApps of the project:

Then view the Pdf/web/viewer.js file.

Ctrl+f Find Default_url will find such var Default_url = ' compressed.tracemonkey-pldi-09.pdf ';

This is the PDFJS default JS file, you can write a demo.jsp page test whether the use of success:

Then visit this page on the Internet successfully, you can see:

This PDF is the default PDF file for Pdfjs.

Then map your project to the outside of the web using the phone to open the view displayed as:

After this success, the next step is to look at your incoming PDF file:

We want to put var default_url = ' compressed.tracemonkey-pldi-09.pdf '; set to null: var default_url = ';

To view the incoming PDF file with a click button event:

If you want to replace the PDFJS default files need to be in ${pagecontext.request.contextpath}/pdf/web/viewer.html?file=? Go to the PDF file that you want to preview.

This ID is the ID of the product information that I want to view in my data table, the background is based on this ID to find the required PDF file (this PDF file was previously passed in the database table).

We pass the PDF in as a file stream, so we need to process the code in the background, that is, the method:/test/displaypdf/{id}. As follows:

This way, you can click on the button on the page to view the corresponding PDF file. In fact, to replace the default PDF file, as long as the first Test successfully opened the JS default to the PDF file, which is the next step to replace the work. For the first time, I've learned so much for the moment, and I'll summarize it. Late additions.

The simple mobile side opens the PDF file.

Related Article

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.