我正在使用fpdf生成pdf文件,并喜欢对齐文本中心。
$pdf->SetTextColor(0,42,92);
$pdf->SetFont('Arial','B',24);
$course = "This & that";
$wi = $pdf->GetStringWidth( $course);
$startPoint = (($pdf->w)/2)-($wi/2);
$pdf->SetXY($startPoint, 195);
$pdf->Cell($wi, 0, $course, 0, 0, 'C');
如果我用
替换$course,一切正常$course = "This that";
我猜字符串中的'&'引起了问题。
尝试这个更改
$pdf->Cell($wi, 0, iconv('UTF-8', 'windows-1252', $course), 0, 0, 'C');