使用 FPDF 使文本在单元格中换行?

发布于 2024-09-14 05:22:21 字数 177 浏览 1 评论 0原文

现在,当我使用带有文本的单元格时,它全部保留在一行上。我知道我可以使用写入功能,但我希望能够指定高度和宽度。

这就是我现在所拥有的,但正如我所说,文本不会换行以保留在尺寸中:

$pdf->Cell( 200, 40, $reportSubtitle, 1, 1 );

Right now when I use a cell with text, it all stays on one line. I know I could use the write function, but I want to be able to specify the height and width.

This is what I have now, but as I said the text does not wrap to stay in the dimensions:

$pdf->Cell( 200, 40, $reportSubtitle, 1, 1 );

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

怎会甘心 2024-09-21 05:22:21

文本换行:

MultiCell 用于打印多行文本。除了 lnlink 之外,它具有与 Cell 相同的属性。

$pdf->MultiCell( 200, 40, $reportSubtitle, 1);

行高:

multiCell 的作用是将给定的文本分散到多个单元格中,这意味着第二个参数定义每行(单个单元格)的高度,而不是所有单元格(集体)的高度。

MultiCell(float w, float h, 字符串 txt [, 混合边框 [, 字符串对齐 [, 布尔填充]]])

您可以阅读完整文档 此处

Text Wrap:

The MultiCell is used for print text with multiple lines. It has the same atributes of Cell except for ln and link.

$pdf->MultiCell( 200, 40, $reportSubtitle, 1);

Line Height:

What multiCell does is to spread the given text into multiple cells, this means that the second parameter defines the height of each line (individual cell) and not the height of all cells (collectively).

MultiCell(float w, float h, string txt [, mixed border [, string align [, boolean fill]]])

You can read the full documentation here.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文