Search code examples
phphtmlfpdf

FPDF - Centering text, Line height


I am using FPDF to draw some text in a PDF. I have implemented this super cool extension class to parse basic HTML into the PDF, but unlike cell and multicell there are no parameters for text alignment and height.

How can I change the text to center align and the line height with $pdf->WriteHTML($text);??


Solution

  • Take a look at this upgraded extension for WriteHTML with text alignment: http://fpdf.de/downloads/addons/41/.

    Example (from the link):

    <?php
    define('FPDF_FONTPATH', 'font/');
    require('WriteHTML.php');
    
    $pdf=new PDF_HTML();
    $pdf->Open();
    $pdf->AddPage();
    $pdf->SetFont('Arial');
    $pdf->WriteHTML('You can<BR><P ALIGN="center">center a line</P>and add a horizontal         rule <BR><HR>');
    $pdf->Output();
    ?>