Page Numbers in the PDF Footer

Topics: Developer Forum
May 6, 2010 at 6:56 AM
Edited May 6, 2010 at 6:57 AM

Hi friends,

I tried to print page numbers into PDF footer.. not sure what's wrong.. but not working for me.. Can anyone help me on this?

This is what I used:

$objPHPExcel->getActiveSheet()->getHeaderFooter()->setOddHeader('&L&BInvoice&RPrinted on &D'); $objPHPExcel->getActiveSheet()->getHeaderFooter()->setOddFooter('&L&B' . $objPHPExcel->getProperties()->getTitle() . '&RPage &P of &N');

Nothing is displayed in my PDF header & footer. Is there anything I should take care when using this?

Thanks & regards, Nissar

Coordinator
May 6, 2010 at 7:31 AM

PDF output doesn't yet support headers and footers per page. The latest SVN code does now support paper size and orientation, but that's the only feature of headers/footers currently supported. It's something that I'm planning work on for the next couple of months.

 

May 6, 2010 at 7:35 AM
Edited May 6, 2010 at 7:36 AM

Thanks for the response.. OK.. do you think that I can get it by customizing myself? If so, can you suggest where should I focus when adding features / fixing bugs for PDF in PHPExcel ?

 

Coordinator
May 6, 2010 at 8:13 AM

@do you think that I can get it by customizing myself?

Depends on a lot of factors, including how comfortable you feel delving into the inwards of PHPExcel and tcpdf.

The PDF writer actually generates an HTML output first, then converts that HTML to PDF. Because the HTML is a single page, and it's the PDF writer that then breaks it down into sheets of A4/Letter size or whatever paper size you're using, the PDF writer handles all the paging, and would need to interpret the header/footer settings from the PHPExcel object. Lines 270/271 of the PDF writer explicitely disable printing or headers/footers. Code would need to enable this, and also set the header/footer to print using the tcpdf setHeaderData() and footer methods based on the PHPExcel_Worksheet_HeaderFooter settings.