Pdf image quality is bad using pdf.js

前端 未结 4 1992
执笔经年
执笔经年 2021-02-13 05:49

I am using pdf.js.

But, image quality of PDF is low quality.

Please tell me solution method.

var TARGET_PAGE = 1; 
var PAGE_SCALE = 1; 

function         


        
4条回答
  •  执念已碎
    2021-02-13 06:15

    I've had the same issue. Just changed 'scale' attribute from 1 to 2 and the quality went way up.

    pdfDoc.getPage(1)
      .then(function (page) {
           var canvas = document.getElementById('myCanvas');
           var ctx = canvas.getContext('2d');
    
           var viewport = page.getViewport(2); // 2 is the 'scale' attr
           canvas.height = viewport.height;
           canvas.width = viewport.width;
    
           var renderContext = {
                  canvasContext: ctx,
                  viewport: viewport
           };
    
           page.render(renderContext);
    });
    

提交回复
热议问题