Customizing Joomla PDF Headers

Joomla has a convenient and useful function to output articles to pdf format. However, the resulting document lacks branding beyond just the title of your Joomla site.

This hack allows you to add an image and a subtitle to your Joomla pdf documents. (This is designed for Joomla 1.5)


Note: This has only been tested with .png images other file types may work.

The first step is to upload the image you would like to use in your header to the libraries/tcpdf/images folder via ftp.

Then you will need to edit the file:
libraries/joomla/document/pdf/pdf.php

On line 213 you will edit the function:
$pdf->setHeaderData(”,0,$this->getTitle(), $this->getHeader());

The first parameter is the image you are using.
Change this to /imagename.png
The / is important you will get an error without it.

The second parameter is the width of the image in milimeters. There is no consistent size to use here, but a good maximum would be 40.

The third parameter is the string which generates the article title. Do not change this it is the most important parameter that Joomla uses by default.

The fourth parameter is the subheader, this is a useful place to put a copyright or just the name of your organization.

The resulting change on line 213 should look something like this.

$pdf->setHeaderData(‘/imagename.png’,30,$this->getTitle(), ‘YourCompany’sName’);

Hopefully this helps you better brand your Joomla site.

Share and Enjoy:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • email
  • Furl
  • StumbleUpon
  • Technorati
  1. Hello James,

    thank you for your hints to customize pdf but I must regret that it doesn’t work on my Website, so I had to remove the modifications.

    I use Joomla 1.5.10 and at the time I modify index.php the pdf generator only produces cryptic signs.

    By the way, the referred peace of code is in line 211 in my index.php, but as I am not very familiar with php I cannot solve the problem myself.

    Best regards,

    Ralf

  2. Ralf, this solution works properly in Joomla 1.5.10. There is no need to modify the index.php file. I have checked pdf generation on your site and it is working properly, if you find someone who is familiar with php, I am certain they will be able to implement the hack on your site.

    • alex mathayes
    • May 28th, 2009

    thanx for this great piece of help….
    I have one small thing which i wanted to know, i have got the header but the title displays just next to the header. is there any way that i can have the title displayed on the next line????

    thnx in advance

  3. Thx works good with joomla 1.5 !!

  4. Works well with joomla 1.5.14. Thanks a lot.

    • slideri812
    • October 14th, 2009

    Thanx a lot, this did the job exactly as needed

    • kristo
    • November 8th, 2009

    Hello James,

    Works exactly as written, great job! Thanks!
    I wonder if there is any possibility to have more formatting options to the header’s look.

    Best regards from Poland!

  5. Great article!
    Might you know how to remove the double space formatting of a new paragraph?
    Thanks

  1. No trackbacks yet.