Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

tcpdf: poor image quality

Tags:

image

pdf

tcpdf

I am using TCPDF to create PDF files converted from HTML input using it's writeHTML() function. However, images within the PDF have poor quality, while the original images have a high quality (as expected). The images are in PNG format. I already tried to use SetJPEGQuality(100), but that had no effect.

What is causing this?

like image 701
asiouser Avatar asked May 17 '11 13:05

asiouser


2 Answers

Try using this:

$pdf->setImageScale(1.53); 

http://sourceforge.net/projects/tcpdf/forums/forum/435311/topic/4831671

like image 166
Abdullah Avatar answered Nov 20 '22 03:11

Abdullah


When using HTML to generate your PDFs you need to manually calculate the images dimensions by dividing it's original width and height by 1.53 and set the result as attributes.

For example, an image with dimensions of 200x100 pixels will become:

<img src="image.jpg" width="131" height="65" />

This is a nasty workaround and doesn't completely remove the blur, but the result is much better than without any scaling.

like image 26
Cobra_Fast Avatar answered Nov 20 '22 02:11

Cobra_Fast