FPDF Header Problem

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
Not sure if this is the correct forum, but since FPDF is a PHP script, I
thought I would give it a try...

I am having a problem getting ANYTHING to print in a header using the FPDF
functions.  I can get text to go into the main body of the PDF file, but
nothing into a header.  I have messed with this for several hours, seached
the web and no luck.  Any help would be greatly appreciated.

Here is my script - which prints "Test Output" in a PDF file with no header
at all.  Any suggestions?


class PDF extends FPDF
//Page header
function Header()
    //Arial bold 15
    //Move to the right
    $this->Cell(30,10,'Header Output',1,1,'C');
    //Line break

$pdf=new FPDF();
$pdf->Cell(40,40,"Test Output");

Re: FPDF Header Problem

Phillip T. Murphy wrote:

Quoted text here. Click to load it

You really should post this on the Forum page of fpdf.org. They have a great
group of peope there and Oliver (author) of PDF is also there all the time.


Quoted text here. Click to load it

You need:



Quoted text here. Click to load it

For our Jaya123 web-system (www.jaya123.com) I've written tens of thousands of
lines of code using the FPDF class so I know a few things.
Hope this helps.

Al C.
Adams-Blake Company, Inc.
JAYA123 - the web-based total-office system for the
small biz. Order entry, billing, bookkeeping, etc. for $14.95
a month. Perfect for the small business or start-up.
See demo at: http://www.jaya123.com

Re: FPDF Header Problem - correction

ooops, Previous answer is not it as you don't need Open(). Your problem is
that you need:

 $pdf=new PDF();

Leave off the "F". By using the "F" you are instantiating a new FPDF class.
However PDF (no F) EXTENDS the FPDF and has a function with YOUR header
stuff. The FPDF header is actually empty and expects to be overriden. When
you just do  $pdf=new FPDF(); you don't get the extension but only an empy
header function.


Quoted text here. Click to load it

Re: FPDF Header Problem - correction

Quoted text here. Click to load it

Al, Thank you!  Wow, I am not sure I would have figured that out on my own,
ever.  As a matter of of fact, I don't see any mention of what you pointed
out in the documentation anywhere.

Thanks again!


Re: FPDF Header Problem - correction

Phillip T. Murphy wrote:

Quoted text here. Click to load it


This example makes use of the Header() and Footer() methods to process page
headers and footers. They are called automatically. They already exist in the
FPDF class but do nothing, therefore we have to extend the class and override

Site Timeline