I'm using print module to generate pdf files from the drupal content. Here I use tcpdf library. The pdf files are working fine. But I want to customize the pdf files, here I want to display header in only the first page of the pdf file and the rest of the pages should display no header, but the footer should be common.

How can I customize the pdf generation? Is there a way that I need to change some thing in template files or library files. I tried to look into the tcpdf's lib-handler files - print_pdf_tcpdf.pages.inc. But I could find nothing related to restricting header.

Help is appreciated.

  • Are you printing one node that has content so long that the pdf has page breaks inserted, or are you printing multiple nodes each on its own pdf page? Aug 25, 2014 at 6:17
  • I'm printing single node that has content
    – GIRI
    Aug 25, 2014 at 15:09
  • In that case my answer is the only way I can see how to do it. With multiple nodes one can reset the page header when adding a new page, but with one node it is not possible as it is just inserting page breaks. Aug 25, 2014 at 16:53

1 Answer 1


This might only be possible if you are printing multiple individual nodes to one PDF by overriding the provided print themes.

A solution that will work no matter what is to add your own class that extends the PrintTCPDF class. You should ideally do this in your own module, but I will show you here how to hack the print_pdf_tcpdf module.

Add a new file to the folder print_pdf->lib_handlers->print_pdf_tcpdf and name it


Add the following contents to that file:


class PrintTCPDF_No_Headers extends PrintTCPDF {
  public function Header() {
    if ($this->page > 1){

Open the print_pdf_tcpdf.pages.inc file and change line 65 - 66 from this:

// create new PDF document
  $pdf = new PrintTCPDF($orientation , 'mm', $paper_size, TRUE);

to this:

// create new PDF document
  $pdf = new PrintTCPDF_No_Headers($orientation , 'mm', $paper_size, TRUE);

Open file print_pdf_tcpdf.info and add the following:

files[] = print_pdf_tcpdf_no_headers.class.inc

Clear your cache and your pdf's will print with a header on page 1 only.

If you want to also print other nodes with headers on all pages you will have to implement some conditional logic in print_pdf_tcpdf.pages.inc file which creates the class needed ( PrintTCPDF or PrintTCPDF_No_Headers)

  • so, with this answer we can't get it done right?? @J.Reynolds
    – GIRI
    Aug 26, 2014 at 5:11
  • With this answer you can get it right. Aug 26, 2014 at 11:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.