Skip to content

Fix the PDF rendering quality#371

Merged
leakymemory merged 1 commit intomasterfrom
bug/pdf-render-quality-fix
May 17, 2017
Merged

Fix the PDF rendering quality#371
leakymemory merged 1 commit intomasterfrom
bug/pdf-render-quality-fix

Conversation

@leakymemory
Copy link
Copy Markdown
Contributor

Fixes #369

The problem we were hitting was because we were setting the viewport scale
to 1 when rendering each of the PDF pages. As I was digging into this, I
found this page, which describes exactly what's going on:

http://stackoverflow.com/questions/35400722/pdf-image-quality-is-bad-using-pdf-js

Basically, this is how it breaks down. We create a canvas element to render the
PDF page onto, and it is set to the viewport height and width. Because
many (most?) PDFs are rendered at a smaller resolution, what ends up
happening is on higher resolution monitors we create a big canvas, but then
render an image that isn't scaled to it right. This causes the pixels to
get spread out and blurriness ensues.

The fix is to set the scaling to "2". We played around with the 3-5 range
and it looked good on high resolutions - but as soon as the same image
was rendered on a smaller resolution screen things went south quick. 2
seems to be the right setting which straddles the fence between the bad
and pretty good.

Fixes #369

The problem we were hitting was because we were setting the viewport scale
to 1 when rendering each of the PDF pages. As I was digging into this, I
found this page, which describes exactly what's going on:

http://stackoverflow.com/questions/35400722/pdf-image-quality-is-bad-using-pdf-js

Basically, this is how it breaks down.  We create a canvas element to render the
PDF page onto, and it is set to the viewport height and width. Because
many (most?) PDFs are rendered at a smaller resolution, what ends up
happening is on higher resolution monitors we create a big canvas, but then
render an image that isn't scaled to it right.  This causes the pixels to
get spread out and blurriness ensues.

The fix is to set the scaling to "2".  We played around with the 3-5 range
and it looked good on high resolutions - but as soon as the same image
was rendered on a smaller resolution screen things went south quick.  2
seems to be the right setting which straddles the fence between the bad
and pretty good.
@mttwc
Copy link
Copy Markdown
Contributor

mttwc commented May 17, 2017

Looks good! (The best fixes are the simplest ones!)

@leakymemory leakymemory merged commit 1dbd58c into master May 17, 2017
@leakymemory leakymemory deleted the bug/pdf-render-quality-fix branch May 17, 2017 16:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The images that are rendered from a PDF are very low quality

3 participants