0

I have a page that I convert to an image using html2canvas and then I convert the image to pdf but I noticed that when I convert the image to PDF, it becomes blurry if I open the pdf on a computer but sharp when I open the pdf on a mobile phone.

The image dimensions is over a thousand pixels so I had to resize it using FPDF so it can fit into the PDF.

I found here https://stackoverflow.com/a/24897867/6879011 that changing the scale should solve it and I think it should work since changing the scale of html2canvas caused the image I generated to be sharper.

My question is, is there a way to change the scale of the FPDF constructor when creating it?

Daenny
  • 21
  • 3
  • When you call `Image()`, you can specify the dimension (by default in mm) that the image will take on the page. If you put an image with more pixels and display it in the same area, then quality will increase. – Olivier Jan 20 '22 at 10:28
  • That is what I'm currently doing. Because the image dimensions are large, I had to specify the width in the Image() functions because if I don't, only part of the image will show in the PDF. But it's still blurry, even when the real image is very sharp. If there was a way I can change the scale https://stackoverflow.com/a/24897867/6879011 that may hopefully work – Daenny Jan 20 '22 at 11:01
  • There is no "scale" to change. FPDF just embeds the image as-is in the document (no pixels are lost). The way it is rendered on screen depends on the viewer. FPDF has no control over it. – Olivier Jan 20 '22 at 11:05
  • You mean if the image is very very sharp. That is how it will show in the PDF? This post says otherwise though https://stackoverflow.com/questions/10040309/how-to-maintain-image-quality-with-fpdf-and-php what could be the cause – Daenny Jan 20 '22 at 12:47

0 Answers0