Trials and tribulations of TCPDF

I've been trying to get the PDF rendering working properly and I find that this is not as simple as I would like!

We are using Joomla which includes TCPDF as the default rendering engine, however the documentation on how to configure is weak to non-existent so I will capture my efforts here so we do not lose.

Configuration options are held in /cms/libraries/joomla/document/pdf/pdf.php rather than in /cms/libraries/tcpdf/config/tcpdf_config.php as you might expect.

The TCPDF library does not deal with images that have sizes specified very well, and seems to scale incorrectly. I have tracked down the problem to the image_scale variable in pdf.php as follows

// Scale ratio for images [number of points in user unit]
var $_image_scale = 1.75;

This is 4 by default (very small image), when set to 1.75 and using standard PNG or JPG images the image scale is fine. If you set scale to less than 1.5, the image expands off the page, and the PDF text gets corrupted. It may that the units need to be corrected (px rather than the default mm), as I have found that setting the image with no size attributes works fine.

The text formatting still needs some work, but this should be quite straightforward to correct.

The test pattern can be viewed here

The final problem to solve is how to get PDF renderer to use the PNG image rather than default SVG which is the preferred option we use on the site as it allows links for the controls. Unfortunately the SVG is too complex for the PDF renderer to handle...

Details on TCPDF API are available fromĀ http://api.joomla.org/1.5/com-tecnick-tcpdf/TCPDF.html

  • Created on .