Mobile Terminal Embedded pdf. js remote request pdf (206), pdf. jspdf

Source: Internet
Author: User

Mobile Terminal Embedded pdf. js remote request pdf (206), pdf. jspdf

Recently, mobile development requires embedding a pdf file for preview. After reading a lot of js components, I chose pdf. js. It is quite convenient to use. There are many tutorials on the Internet.

However, the following problem occurs during use (I am working on the IOS system ):

The problem is that the server partially responds to the http get request and the pdf cannot be opened. I tried many methods and failed to modify the request's first-class method;

Finally, compatibility. js in pdf. js is queried to find that it is used to determine disableRange and disableStream. The above request problems are caused by no judgment on the IOS system;

The above problems were successfully solved by referring to the solution from the experts in github.

Method: 1. Add the ios system judgment in compatibility. js;

Var isIOS = // \ B (iPad | iPhone | iPod )(? =;)/. Test (navigator. userAgent );

2. add this item in judgment

If (isSafari | isOldAndroid | isChromeWithRangeBug | isIOS ){
Using Js. disableRange = true;
Jsonjs. disableStream = true;
}

3. Save it;

Note: The above is a judgment on commonly used browsers and mobile terminal systems, such as other browsers or systems, can be expanded according to the actual situation.

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.