react-pdf icon indicating copy to clipboard operation
react-pdf copied to clipboard

Blurry PDF uploads

Open elchaparrito1 opened this issue 2 years ago • 4 comments

Before you start - checklist

  • [X] I followed instructions in documentation written for my React-PDF version
  • [X] I have checked if this bug is not already reported
  • [X] I have checked if an issue is not listed in Known issues
  • [X] If I have a problem with PDF rendering, I checked if my PDF renders properly in PDF.js demo

Description

I have an issue where there seems to be a decent level of px degradation when a pdf is uploaded to company AWS S3, and a customer goes to view it on company's platform. It isn't way noticeable, unless the PDF image is already of lower quality. Example of section of PDF prior to upload (is from customer invoice so don't want to show whole PDF):

Screen Shot 2022-02-28 at 12 45 53 PM

And what is looks like after upload, and is clicked for viewing:

Screen Shot 2022-02-28 at 12 45 43 PM

We were using version 5.1.0 and upgraded to 5.7.1 and this did not help the quality.

Steps to reproduce

Use PDF.js Demo locally to test quality of PDF for viewing online.

Expected behavior

Expected behavior is for pdf image to at least have the same px quality as before.

Actual behavior

Appears to be some degradation after PDF is ran though API services for upload.

Additional information

No response

Environment

  • Browser (if applicable):
  • React-PDF version:
  • React version:
  • Webpack version (if applicable):

elchaparrito1 avatar Feb 28 '22 20:02 elchaparrito1

A bit late but commenting for ideas

I'm assuming you checked that after uploading your PDF/viewing it whether by public/direct S3 url or downloading from S3 and opening in a browser it's not blurry there?

If it looks good above then I would check the scale of the rendered react-pdf size (checking if modifying it improves quality (width/height or scale values)).

From my experience our PDFs were getting blurry because I was taking DOM screenshots/uploading that vs. using the original pdf/stacking changes on top of it using pdfkit on the backend.

jdc-cunningham avatar Apr 06 '22 18:04 jdc-cunningham

Sorry A bit late. is this solved? But it's okey, I hope this helps the next reader.

have you tried add scale props to Page component. If not. To overcome blurry you can add props scale={5}. you can try replace 5 to 1,2,3, or you can try another number.

It's works for me.

otnansirk avatar Apr 25 '22 15:04 otnansirk

Scale should be automatically multiplied by devicePixelRatio so that shouldn't be the problem. At least on all my test devices PDFs are rendering super sharp.

wojtekmaj avatar Apr 25 '22 19:04 wojtekmaj

Sorry. Coming back late to this. I will try the scale prop and see if that offers any improvements.

elchaparrito1 avatar May 19 '22 21:05 elchaparrito1

This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this issue will be closed in 14 days.

github-actions[bot] avatar Aug 22 '22 00:08 github-actions[bot]

This issue was closed because it has been stalled for 14 days with no activity.

github-actions[bot] avatar Sep 05 '22 00:09 github-actions[bot]

,2,3, or you can try another num

So multiply what with window.devicePixelRatio?

Example: <Document scale={window.devicePixelRatio*}/>

georgiossalon avatar Feb 06 '23 15:02 georgiossalon

Did anyone found the solution here ?

tsaxena4k avatar Apr 20 '23 14:04 tsaxena4k

Scale is automatically multipled by devicePixelRatio so that shouldn't be a problem for a long time now. If it is, I'm gonna need a repro.

wojtekmaj avatar Apr 21 '23 10:04 wojtekmaj

have you tried add scale props to Page component. If not. To overcome blurry you can add props scale={5}. you can try replace 5 to 1,2,3, or you can try another number. scale={5} It's works for me.

VikasPathaniaa avatar Feb 16 '24 06:02 VikasPathaniaa

Why this issues added closed?

Anhaachan avatar Mar 25 '24 08:03 Anhaachan