首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在MultiCell FPDF中手动添加换行符

问在MultiCell FPDF中手动添加换行符
EN

Stack Overflow用户
提问于 2021-09-14 09:53:40
回答 1查看 42关注 0票数 1

我有一个很长的文本,我想添加到FPDF格式,我正在使用MultiCell()来实现这一点,它工作得很好。我面临的唯一问题是文本几乎到了页面右侧的末尾。我不希望这种情况发生,相反,我希望多个单元格添加一个换行符,并继续到下一行。如何手动指定MultiCell添加换行符?我可以提供x轴的限制或每行字符的限制吗?

代码语言:javascript
复制
<?php 
header('Content-Type: text/html; charset=utf-8');

require_once __DIR__ . '/vendor/autoload.php';

require_once('FPDI/autoload.php');
require_once('fpdf/fpdf.php');
require_once('FPDI/Fpdi.php'); 

$pdf = new FPDI();

$pdf->AddPage(); 

$pdf->setSourceFile('Literature.pdf'); 

$tplIdx = $pdf->importPage(1); 

$pdf->useTemplate($tplIdx, 0, 0, 297, 420, true); 

$pdf->SetTextColor(0, 0, 40);

$Text = "As they rounded a bend in the path that ran beside the river, Lara recognized the silhouette of a fig tree atop a nearby hill. The weather was hot and the days were long. The fig tree was in full leaf, but not yet bearing fruit. Soon Lara spotted other landmarks—an outcropping of limestone beside the path that had a silhouette like a man’s face, a marshy spot beside the river where the waterfowl were easily startled, a tall tree that looked like a man with his arms upraised. They were drawing near to the place where there was an island in the river. The island was a good spot to make camp. They would sleep on the island tonight."

$pdf->SetXY(10, 50);
$pdf->Multicell(0, 8, $Text, 0, 'L', false); //Facing problem here

...

...

?>
EN

回答 1

Stack Overflow用户

发布于 2021-09-14 17:35:09

MultiCell的第一个参数是0,手册中提到:

单元格的

宽度。如果为0,则它们向上延伸到页面的右边距。

因此,将该零更改为您想要宽度。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/69175639

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档