How to improve display quality in pdf.js

Arthur picture Arthur · Feb 12, 2014 · Viewed 8.3k times · Source

I'm using open source library for PDF documents from mozilla(pdf.JS). When i'm trying to open pdf documents with bad quality, viewer displays it with VERY BAD quality.

enter image description here

But if I open it in reader, or in browser (drag/drop into new window), whis document displays well

enter image description here

Is it possible to change? Here is this library on github mozilla pdf.js

Answer

M. Codina picture M. Codina · May 13, 2017

Maybe it's an issue related with pixel ratio, it used to happen to me when device pixel ratio is bigger than 1 (for example iPhone, iPad, etc.. you can read this question for a better explanation.

Just try that file on PDF.js Viewer. If it works like expected, you must check how PDF.js works with pixel ratio > 1 here. What library basically does is:

canvas.width = viewport.width * window.devicePixelRatio;
canvas.styles.width = viewport.width + 'px'; // Note: The px unit is required here

But you must check how PDF.js works for better perfomance