FPDF will not correctly center text

I am trying to use FPDF to display the contents of a bachelor / master cover.

I need to display the Czech alphabet, including punctuation characters (e.g. ř, č, ž, ý, ě). Therefore, I created FPDF font files at http://fpdf.fruit-lab.de/index.php from the local Times New Roman TTF font file.

I use the following code to make a cover.

function toISO($text) { return iconv('UTF-8', 'ISO-8859-2', $text); } function buildImpressionPDF($school, $faculty, $thesisType, $firstname, $surname, $year) { $pdf = new FPDF(); $pdf->AddPage(); $pdf->AddFont('times', '', 'times.php'); $pdf->SetFont('times', '', 18); $pdf->setMargins(0, 0, 0); $pdf->SetAutoPageBreak(false); $pdf->Cell(0, 20, toISO($school), 0, 0, 'C'); $pdf->SetY(20); $pdf->Cell(0, 20, toISO($faculty), 0, 0, 'C'); $pdf->SetY(($pdf->h / 2) - 10); $pdf->Cell(0, 20, toISO($thesisType), 0, 0, 'C'); $pdf->SetY(-40); $pdf->Cell(0, 20, toISO($firstname . ' ' . $surname), 0, 0, 'C'); $pdf->SetY(-30); $pdf->Cell(0, 20, toISO($year), 0, 0, 'C'); return $pdf; } 

The text displays a penalty, including punctuation, but is not properly justified - some lines are placed more to the right than others.

I suspect this might be a custom font problem. When I used the original FPDF fonts, it seemed justified (but I did not examine it completely), but, of course, did not display the punctuation properly.

What am I doing wrong?

+4
source share
1 answer

Please use TCPDF instead of FPDF. Or try this

 $pdf->Cell(20,10,'Title',1,1,'C'); 
0
source

All Articles