我试图用FPDF在PDF文档上显示一些数据,我的问题是我无法限制字符串的字符数,有时宽度超过了,我已经使用MultiCell,但我想设置一个字符的限制,使用FPDF限制字符串中的字符数
我试图用我的函数自定义回声来解决这个问题,但显然不能使用fpdf我不知道会发生什么。
function custom_echo($x, $length)
{
if(strlen($x)<=$length)
{
echo $x;
}
else
{
$y=substr($x,0,$length) . '...';
echo $y;
}
}
$message= "HELLO WORLD";
$pdf=new FPDF();
$pdf->SetLeftMargin(0);
$pdf->AddPage();
$pdf->MultiCell(95, 6, utf8_decode(custom_echo($message,5)), 0, 1);
// already tried this
$pdf->MultiCell(95, 6, custom_echo(utf8_decode($message),5), 0, 1);
$pdf->Output();
我不能相信那个错误,谢谢你的时间! –
@edgarreyes我也犯过这样的错误。 – manassehkatz