PDF.JS:如何分别缩放页面?

问题描述

我一直在尝试使pdfjs查看器与我的PDF一起使用,这些PDF具有不同的页面大小。 我正在从这里使用PDFViewer:https://cdnjs.cloudflare.com/ajax/libs/pdf.js/2.5.207/pdf_viewer.js

不幸的是,当使用pdfViewer._setScale(“ page-fit”);时,似乎只考虑pdf的第一页,从而使其他页面缩放错误。

我尝试过更改_setScale函数以查看所有页面,但这完全弄乱了比例,就像这样(第5750ff行):

  // new: 
  let pageWidthScale = 20000;
  let pageHeightScale = 20000;
  for (var i = 0; i < this._pages.length; i++ ) {
    pageWidthScale = Math.min((this.container.clientWidth - hPadding) / this._pages[i].width * this._pages[i].scale);
    pageHeightScale = Math.min((this.container.clientWidth - hPadding) / this._pages[i].height * this._pages[i].scale);
  }



// was:
// const pageWidthScale = (this.container.clientWidth - hPadding) / currentPage.width * currentPage.scale;
// const pageHeightScale = (this.container.clientHeight - vPadding) / currentPage.height * currentPage.scale;

我希望您能向正确的方向发展。我正在这样调用_setScale函数:

eventBus.on("pagesinit",function () { pdfViewer._setScale("page-fit"); }

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...