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.