How to Center Text in FPDF?

NORM picture NORM · Jan 20, 2011 · Viewed 49.4k times · Source

How can I have this generated text appear centered in the page.

Generated = $_POST method ... so I don't know how long will the text in input be. I need to have a pre-determined center parameter somehow.

Any ideas? Maybe like this:

MultiCell(0,$height,"text",0,'C') ?

Answer

BlackMagic picture BlackMagic · Jun 16, 2011

Normally it's $pdf->Cell(0, $height, "text", 0, 0, 'C'); but if you're doing it in a Header or Footer function it's $this->Cell(0, $height, "text", 0, 0, 'C'). Don't forget to declare $height as a global if you're doing this in a function() call.