PDF.js跨域(django后端处理数据流方法)

前言

PDF.js is a Portable Document Format (PDF) viewer that is built with HTML5. 下载地址https://github.com/mozilla/pdf.js/releases

跨域

网上也有一些设置nginx服务器实现跨域,这里只考虑是把pdf文件请求到后端返回数据流的形式来实现

  • 首先
  • 修改viewer.js
function webViewerLoad() {
  var config = getViewerConfiguration();
  window.PDFViewerApplication = pdfjsWebApp.PDFViewerApplication;
  window.PDFViewerApplicationOptions = pdfjsWebAppOptions.AppOptions;
  var event = document.createEvent('CustomEvent');
  event.initCustomEvent('webviewerloaded …
more ...