Oct 112010

Phoca PDF is a great tool to use if you want to quickly add a custom header and footer to your PDFs. The component, the plugin, and your select font should all be installed, but installation is easy.

What didn’t quite work for me is that my requirement was to print the logo header only on the first page (rather than at the top of every page), and to have no footer. The other issue is that while Phoco had options to cache the generated PDFs, it appeared that they were always generated on-the-fly, and with much longer processing time before showing the PDF to the visitor than with default Joomla.

Rather than try to get Phoca to do what I needed (which would’ve been a bit more time consuming as Phoca is more complex), I made the following modifications to these Joomla files:
(line numbers are approximate)

libraries/joomla/document/pdf/pdf.php

Lines 33-47, adjust var $_margin_top and $_margin_bottom depending on the height of your logo
Line 211
, comment out these lines:

// Set PDF Header data
// $pdf->setHeaderData(”,0,$this->getTitle(), $this->getHeader());  // this line prints the header on each page

libraries/tcpdf/tcpdf.php

line 561, set var $print_footer = false;
leave as true to get the default Joomla PDF footer,
setting var $print_header=false; will render blank PDFs, leave that value as true.

components/com_content/views/article/view.pdf.php

line 81, modify the code section to look like this:

// prepare header lines
// $document->setHeader($this->_getHeaderText($article, $params));
echo ‘<img src=”http://www.domainname.com/images/stories/printlogo.png” /><br /><br />’;
echo ‘<h1>’ . $article->title . ‘</h1>’;
echo $article->text;

There you go!

One Response to “Add logo to Joomla PDFs”

  1. ana says:

    lover your tutorial, but when I put the image and then the route, it “comments” everything after the “http:” because of the “//” in the addres… how can I solve this? I try to put the image next to the “view.pdf.php” so I will call it only “echo ‘’; but then it gives me an error: ” Warning: getimagesize(logo.gif) [function.getimagesize]: failed to open stream: No such file or directory in C:\Archivos de programa\xampp\htdocs\joomla\libraries\tcpdf\tcpdf.php on line 3694
    TCPDF error: Missing or incorrect image file: logo.gif” (I am using xampp before doing it online) how can I solve this?

    Thanks!
    Ana

Leave a Reply

(required)

(required)

© 2012 guyzero.com Hosted by BartoliTech.com