Pdf image quality is bad using pdf.js

前端 未结 4 2065
执笔经年
执笔经年 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:10

    Just put the canvas inside a wrapper

    , and set its rendered size relative to the wrapper. Then you can set the logical size of the canvas as large as the viewport to achieve high dpi without changing its actual size on the screen. For example,

    var scale = 5;
    var viewport = page.getViewport(scale);
    canvas.width = viewport.width;
    canvas.height = viewport.height;
    canvas.style.width = "100%";
    canvas.style.height = "100%";
    wrapper.style.width = Math.floor(viewport.width/scale) + 'pt';
    wrapper.style.height = Math.floor(viewport.height/scale) + 'pt';
    

提交回复
热议问题