细胞的 fpdf 对齐

发布于 2024-11-05 11:31:39 字数 772 浏览 5 评论 0原文

我正在尝试使用 fpdf 生成 PDF,但遇到一个小问题

,我需要 2 个单元格,如下所示:

-------------------------  -------------------------
|  Address Line 1          |       Version         |
|  Address Line 2          |         1.0           |
|  City                    |       06/05/2011      | 
-------------------------  -------------------------

我尝试使用 MultiCell() 但没有运气。

$address = '
    Address Line 1
    Address Line 2
    City
    Postcode';
$pdf->MultiCell(133.5, 2.7, $address, 'L', 'L');

$version = '
    Version 
    1.0
    06/05/2011';
$pdf->MultiCell(53.5, 2.7, $version, 'R', 'R');

我认为我可以将“浮动”设置为向左或向右,这就是文档所说的,但这似乎不起作用。它只是在地址下方列出版本多单元格,而不是在地址右侧。

有谁知道为什么会这样?

谢谢

I'm trying to generate a PDF using fpdf and I'm having a small problem

I need to have 2 cells, like the following:

-------------------------  -------------------------
|  Address Line 1          |       Version         |
|  Address Line 2          |         1.0           |
|  City                    |       06/05/2011      | 
-------------------------  -------------------------

I've tried using MultiCell() but with no luck.

$address = '
    Address Line 1
    Address Line 2
    City
    Postcode';
$pdf->MultiCell(133.5, 2.7, $address, 'L', 'L');

$version = '
    Version 
    1.0
    06/05/2011';
$pdf->MultiCell(53.5, 2.7, $version, 'R', 'R');

I thought that I could possibly set the 'float' as it was left or right, which is what the docs say, but this doesn't seem to work. It just lists the Version multicell below the address and not to the right of it.

Does anyone have any idea why this would be?

Thanks

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

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

发布评论

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

评论(1

女中豪杰 2024-11-12 11:31:39

http://www.fpdf.org/en/tutorial/tuto5.htm

只需使用:

$pdf->Cell(width, height, text, border, position-next-cell, alignment);

所以这意味着,在“position-next-cell”之后添加一列应该是 0 您正在寻找的可能是:

$pdf->Cell(133.5, 2.7, $address, 0, 0, 'L');
$pdf->Cell(53.5, 2.7, $version, 0, 1, 'L');

在第二次调用之后,您注意到 1 这意味着下一个单元格被放置在下面而不是后面(0 会这样做。)

http://www.fpdf.org/en/tutorial/tuto5.htm:

Just use:

$pdf->Cell(width, height, text, border, position-next-cell, alignment);

So this means, to add a column afterwards 'position-next-cell' should be 0 what you're looking for is probably:

$pdf->Cell(133.5, 2.7, $address, 0, 0, 'L');
$pdf->Cell(53.5, 2.7, $version, 0, 1, 'L');

After the 2nd call you noticed the 1 which means a next cell is being placed underneath and not after (which the 0 would do.)

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