Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document is blurry #14724

Closed
mikecoulhs opened this issue Mar 28, 2022 · 16 comments · Fixed by #18035
Closed

Document is blurry #14724

mikecoulhs opened this issue Mar 28, 2022 · 16 comments · Fixed by #18035
Assignees

Comments

@mikecoulhs
Copy link

Attach (recommended) or Link to PDF file here:
Infographic_EAP_EN_v2 (1).pdf

Configuration:

  • Web browser and its version:
    Chrome Version 99.0.4844.51 (Official Build) (x86_64)
  • Operating system and its version:
    macOS Catalina 10.15.7
  • PDF.js version:
    Repros with version at PDF.js Demo Viewer
  • Is a browser extension:
    No

Steps to reproduce the problem:

  1. Go to https://mozilla.github.io/pdf.js/web/viewer.html
  2. Open the file
    This is how the document appears in Adobe Acrobat Reader:
    image

This is how it appears in the viewer. (Please view in full size) Note the lack of crispness of the text in particular.
image

Thank you!

@luisberth

This comment was marked as off-topic.

@mikecoulhs
Copy link
Author

HI @luisberth , I just tried it in firefox and it appears the same. The text is similarly blurry and the document is clipped halfway down.

@SamyCookie
Copy link

SamyCookie commented Mar 29, 2022

Hello, I also confirm the issue on a Linux Debian Bookworm 64bits with Firefox 98 and the embedded PDF.js reader (v2.13.93).

@vlakken
Copy link

vlakken commented Mar 29, 2022

I noticed this also, in my case always returning true here made it better:

https://github.com/mozilla/pdf.js/blob/master/src/display/canvas.js#L1045

@calixteman
Copy link
Contributor

I think the text blurriness is due to:

this.ctx.drawImage(groupCtx.canvas, 0, 0);

where there is a scaleY !== 1 and very likely it's the same cause for the images.

@margaux0
Copy link

margaux0 commented May 4, 2022

We are having the same issue. Text in high quality images in the pdf is not rendered properly. We have tested the pdf in the web viewer (https://mozilla.github.io/pdf.js/web/viewer.html) to check if we were rendering incorrectly, but have found the same behaviour occurs there.

@calixteman calixteman self-assigned this May 4, 2022
@mikecoulhs
Copy link
Author

mikecoulhs commented Jul 8, 2022

Hi calixteman! I was wondering (hoping?) if there was any progress on this? We're seeing it on a fair number of documents (some worse than others). Interestingly, it seems like this might be a regression - we have a very old version of pdf.js (1.10.129) that doesn't exhibit the blurriness (at least for one document I've looked at) Thanks!

@mikeweilgart
Copy link

mikeweilgart commented Jul 12, 2022

I just noticed this stems from Firefox. I've noticed now on a few financial websites that when I attempt to view OR PRINT a PDF directly from Firefox, the result is blurry and unusable. Instead I have to download the PDF and then print it from Acrobat Reader to get a crisp printout.

I also found these other bug reports which seem to be about the same problem:

#14147
https://bugzilla.mozilla.org/show_bug.cgi?id=1506953

@marco-c
Copy link
Contributor

marco-c commented Jul 12, 2022

I just noticed this stems from Firefox. I've noticed now on a few financial websites that when I attempt to view OR PRINT a PDF directly from Firefox, the result is blurry and unusable. Instead I have to download the PDF and then print it from Acrobat Reader to get a crisp printout.

This is a different problem, what you're seeing is https://bugzilla.mozilla.org/show_bug.cgi?id=1274502 (https://bugzilla.mozilla.org/show_bug.cgi?id=1774631 or https://bugzilla.mozilla.org/show_bug.cgi?id=1777209), which are fixed in Firefox 104.

I also found these other bug reports which seem to be about the same problem:

#14147
https://bugzilla.mozilla.org/show_bug.cgi?id=1506953

Yes, this is a duplicate of #14147.

@marco-c marco-c closed this as not planned Won't fix, can't repro, duplicate, stale Jul 12, 2022
@mikecoulhs
Copy link
Author

@marco-c I'm a little confused - as reported, this ticket repros in Google Chrome.

@marco-c
Copy link
Contributor

marco-c commented Jul 12, 2022

It also reproduces in Firefox, the underlying bug is the same.

@nwang-highspot
Copy link

I think the text blurriness is due to:

this.ctx.drawImage(groupCtx.canvas, 0, 0);

where there is a scaleY !== 1 and very likely it's the same cause for the images.

Hi @calixteman How can we fix the problem, seems I can still reproduce the issue.

@marco-c
Copy link
Contributor

marco-c commented Jul 14, 2022

This issue is not closed because it was fixed, it was closed as a duplicate of #14147.

@calixteman
Copy link
Contributor

In order to handle correctly transparency, we use some intermediate canvas and sometimes they can be too big.
So in order to prevent some allocation issues, the group is drawn on a smaller canvas and then resize thanks to a scale transformation:

scaleY = drawnHeight / MAX_GROUP_SIZE;

In the pdf attached to this issue, the bounding box used to compute the canvas dimensions is [ 0, 0, 5950, 50210 ] and the height here is a way too big.

@nwang-highspot
Copy link

@calixteman So what is the recommended size(height) for the canvas dimensions?

@wmerobertson
Copy link

wmerobertson commented Mar 27, 2023

This looks to be a duplicate of #14982. It is fixed by disabling this block: pdf.js/src/display/canvas.js

calixteman added a commit to calixteman/pdf.js that referenced this issue May 1, 2024
…r not

It fixes issues mozilla#14982 and mozilla#14724.
The main problem of upscaling a canvas is that it can induces some pixelation
(see issue mozilla#14724). So this patch is just removing the limit and as a side
effect it fixes issue mozilla#14982.
As far as I can tell, in looking different profiles (especially some memory profile)
in using the Firefox profiler, I don't see any noticeable difference in term of
memory use.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.