pdf.js Firefox failed to preview large files and previewed successfully after modification (solution 1)

The detailed code for solving the problem I encountered has been pasted. I hope it will be helpful to those who encounter the same problem. The original code of the project I made uses the pdf.js plug-in to preview the file online. It can be previewed normally on Google, but it is placed in If there are more than 800k on Firefox, an error will appear. The screenshot of the error is as follows:

The page response indicates that the data has been truncated. After Baidu failed to find any results, it was once thought that there was a problem with the Firefox browser. After searching, the original code was modified without finding the specific reason, and the original back-end code was first posted to make an error. recording:

The front-end code is as shown in Figure 1 and Figure 2 screenshots:

The above method is normal in Google online preview, but the larger Firefox file will fail to preview. After verification, the code in Figure 1 and Figure 2 above will be commented, and then the page preview method will be modified as follows:

Modify the screenshot in viewer.js:

The screenshot of the back-end code modification is as follows:

So far, the online preview is normal regardless of size, as shown in the screenshot:

 

Guess you like

Origin blog.csdn.net/weixin_47385625/article/details/111354163