Mobile Display PDF (open PDF Online)

Source: Internet
Author: User

Requirement: Open PDF in mobile browser or other browser

Preparation: Front-end plugin: Find Pdf.js website address: http://mozilla.github.io/pdf.js/Download demo in official website

Note: The PDF demo must be open in a Web project, so you must deploy the Web project

Official API, as follows

Picture The file directory structure of the box, please do not change, directly in the download demo copy out

Demo Address:

A directory of files in a Web project

testpdf.jsp

<%@ Pagelanguage= "Java"ContentType= "text/html; charset=utf-8"pageencoding= "Iso-8859-1"%><!DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" "Http://www.w3.org/TR/html4/loose.dtd "><HTML><Head><Metahttp-equiv= "Content-type"content= "text/html; charset=utf-8"><title>Insert Title here</title></Head><Body>        <Button>Browse PDF Online</Button></Body><Scripttype= "Text/javascript">function Browserpdf () {$.ajax ({url: ' http://192.168.1.110:8060/mypdf/testPDF.pdf,  Type: "Get", Success:function (XHR, data) {if (navigator.userAgent.indexOf (' Android ') >-1) {//To determine whether the mobile is Android or iOS, if Android is using the PDF plugin window.location.href = "http://192.168                .1.110:8060/js/web/viewer.html?file= "+url;                    } else {//ios Opens the pdf//window.location.href = URL directly;                Window.location.href = "http://192.168.1.110:8060/js/web/viewer.html?file=" +url; }}, Error:function () {//window.location.href = ' ${ctx}/core/user.androidpdf . do?mid= ' +mid+ '&name= "+storagename+"&realname= "+realname;            Window.location.href = "http://192.168.1.110:8060/js/web/viewer.html?file=" +url;    }        }); }        </Script></HTML>

Project is started and then accessed

Mobile Display PDF (open PDF Online)

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.