Search code examples
phpencodingfpdf

FPDF encoding in footer


I have a problem using FPDF while using special character like é, è or à.

I used $é = iconv('UTF-8', 'windows-1252', 'é'); and then I use it like this $pdf->Cell(0,0,'Donn'.$é.'es',0,1);. I know this is not the best way to work with but that's not a big deal...

The real problem is that we can not use variable in header or footer. Or I have to write a sentence in the footer with special character. How can I proceed to this ?


Solution

  • I had to use a global variable.

    In the main code

    global $à ;
    $à = iconv('UTF-8', 'windows-1252', 'à');
    

    In the header/footer

    $à  = $GLOBALS['à'];