Pdfjs viewer with external file upload

独自空忆成欢 提交于 2021-02-11 06:30:23

问题


I am loading the pdf.js viewer in my webpage in a div using the pdf.js API methods such as run and open.

In this page I also have a file upload section to attach related documents.

The issue is when I upload a document in the file upload section, using dropzone, the pdf viewer thinks I am uploading a document to it and changes the existing document. Is there a setting to turn this off? I thought there would be something in network.js but I haven't found anything promising yet.


回答1:


Here is the offending part in PDFViewerApplication, it adds a global change event listener and changes the pdf if it's a file input with files selected.

Unfortunately there is no settings flag to disable this behaviour, no reference to the listener function to remove it, and also no way to cancel or change the event (it would also break other parts of the app), so you'll have to modify this code to remove it. Seems like the listener just dispatches a new internal fileinputchange event which is only used for this, so you only need to comment out this line.



来源:https://stackoverflow.com/questions/39804363/pdfjs-viewer-with-external-file-upload

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!