如果有此FPDF代码:
$pdf->Cell(65 ,3, "Helene",1, 1, 'R');
$pdf->Ln(2);
$pdf->Cell(65 ,3, "Hélène",1, 1, 'R');
这给出了两个不同的结果:
为什么口音会引发这个问题? “Helene”和“Hélène”之间存在转换,因此“Hélène”不是右对齐的,但“Helene”是右对齐的。难道是字体不兼容UTF-8的问题?
<?php
// Appel de la librairie FPDF
require("fpdf/fpdf.php");
// Création de la class PDF
class PDF extends FPDF {
function Header()
{
}
}
// Activation de la classe
$pdf = new PDF('L', 'mm', array(85, 54));
$HeaderVisible=1;
$pdf->SetFont('Arial','',12);
$pdf->SetTextColor(128, 128, 128); //couleur grise
$pdf->AddPage('L');
$pdf->Cell(65 ,3, "Hélène",1, 1, 'R');
$pdf->Ln(2);
$pdf->Cell(65 ,3, "Helene",1, 1, 'R');
$nom = 'test2.pdf';
exec ("rm test2.pdf");
// Envoi des en-têtes
header("Cache-Control: no-cache, no-store, must-revalidate");
header("Pragma: no-cache");
header("Expires: 0");
header('Content-Type: application/pdf');
header('Content-Disposition: inline; filename="'.$nom.'"');
$pdf->Output($nom);
echo $nom;
?>
您致电的简单解决方案:
$pdf->Cell(65 ,3, "Helene",1, 1, 'R');
```
Change the 'R' to 'C' for centered
or
Change the 'R' to 'L' for left.