FPDI新行后......字符

时间:2014-06-17 07:11:37

标签: pdf pdf-generation fpdf fpdi

我正在制作 FPDI PDF。这就是我现在所做的:

libraries_load('fpdi');

$pdf = new FPDI();  

$path = drupal_get_path('theme', 'xmed') . '/docs/verkocht_template.pdf';

$pdf->setSourceFile(realpath($path)); 
$tplIdx = $pdf->importPage(1, '/MediaBox');

$pdf->addPage();
$pdf->useTemplate($tplIdx, 0, 0, 210);

$path = drupal_get_path('theme', 'xmed') . '/fonts/lato.php';

$pdf->AddFont('lato-light-webfont','','lato-light-webfont.php');
$pdf->SetFont('lato-light-webfont', '', 14);
$pdf->SetTextColor(0, 0, 0);

$pdf->SetXY(47, 71);
$pdf->Write(0, $name);

我还在我的PDF上放置了一些其他变量。这是现在的结果:

enter image description here

但是你可以看到$ name变量很长......我试过这个:

$naam = wordwrap($naam, 20);

但是这给了我这个结果:

enter image description here

解决此问题的最佳解决方案是什么?

1 个答案:

答案 0 :(得分:3)

只需使用MultiCell()而不是Write()。它允许您定义文本将自动包装的宽度(第一个参数)。