使用pdf.js,我最多只能读取2MB的pdf,而不能读取更多,为什么?

时间:2019-06-19 11:34:37

标签: javascript php codeigniter pdf.js

某些页面被读取后出现错误

  

“ pdf.js:25744未捕获的DOMException:无法在'DedicatedWorkerGlobalScope'上执行'postMessage':无法克隆数据,内存不足。”

仅当我使用2 MB以上的文件时,这种情况才会发生。

如何在pdf.js文件中更改最大允许文件?

MessageHandler.prototype = {
  on: function messageHandlerOn(actionName, handler, scope) {
    var ah = this.actionHandler;
    if (ah[actionName]) {
      throw 'There is already an actionName called "' + actionName + '"';
    }
    ah[actionName] = [handler, scope];
  },
  send: function messageHandlerSend(actionName, data) {
    this.comObj.postMessage({ //console is showing error in this line
      action: actionName,
      data: data
    });
  }
};

2 个答案:

答案 0 :(得分:0)

尝试在您的php.ini文件中增加upload_max_filesize和post_max_size(通常您会找到2M)

答案 1 :(得分:0)

增加post_max_sizeupload_max_filesize。您可以在php.ini中设置2个不同的位置,因为upload_max_filesize的默认PHP值为2 MB,post_max_size的默认PHP值为8 MB。

; Maximum allowed size for uploaded files.
upload_max_filesize = 20M

; Must be greater than or equal to upload_max_filesize
post_max_size = 20M

此更改需要重新启动服务器