11

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?

asiouser
  • 241
  • 1
  • 3
  • 5

4 Answers4

8

Try using this:

$pdf->setImageScale(1.53); 

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

Abdullah
  • 192
  • 2
  • 6
  • When using HTML-input, this seems to scale element dimensions as well, which results in broken tables and layouts. :( – Cobra_Fast Jan 07 '13 at 11:25
4

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.

Cobra_Fast
  • 15,671
  • 8
  • 57
  • 102
0

Try To convert your Image to JPG or JPEG first. Until Now, I DOnt have a problem to convert image with TCPDF. I Think TCPDF is powerfull, because it can convert arabic language too. I HAve try convert arabic font with fpdf n it still fail

MudMan23
  • 821
  • 3
  • 10
  • 17
0

Little Up.

I'd same quality problem and I solved it... When you save your picture, do it in 8bits instead of 24bits and you will see a "beautiful anti-aliasing".