pdf.js在线打印在IE11上打印不全

我们会遇到:用pdf.js插件在线打印pdf文档,在chrome上正常预览和打印,在IE11上打印时下半页空白。pdf内容是繁体,另外发现同一个pdf在chrome和IE中字体大小不同,打印时的页边距也不同,但调整无效

参考了这些网址:

https://ask.csdn.net/questions/270699  //没有成功

https://blog.csdn.net/tds411255224/article/details/79297666 //打印全了,但是失针模糊了

于是参看了:

https://github.com/mozilla/pdf.js/issues/3983网址

In order to fix printing issue where only half the page is being printed:

  var PRINT_OUTPUT_SCALE = 4; //change (increase to improve quality)
  var canvas = document.createElement('canvas');

  // The logical size of the canvas.
  canvas.width = Math.floor(viewport.width) * PRINT_OUTPUT_SCALE;
  canvas.height = Math.floor(viewport.height) * PRINT_OUTPUT_SCALE;

  // The rendered size of the canvas, relative to the size of canvasWrapper.
  canvas.style.width = '100%'; //change
  canvas.style.height = '100%'; //change

  var cssScale = 'scale(1,1)'; //change

Explanation of changes:

- Increase the PRINT_OUTPUT_SCALE to improve quality.
- Change canvas.style.width and canvas.style.height to be 100%.
- Change cssScale to be (1,1) to preserve scale

改完以后就可以了。没有失针,也都全。

不过上面有好多方法都可以试试的。 

猜你喜欢

转载自blog.csdn.net/wenfeifang/article/details/83106351