fpdf单元格的排列[英] fpdf alignment of cells

本文是小编为大家收集整理的关于fpdf单元格的排列的处理/解决方法,可以参考本文帮助大家快速定位并解决问题,中文翻译不准确的可切换到English标签页查看源文。

问题描述

我正在尝试使用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');

我以为我可以在左右设置"浮点",这是文档所说的,但这似乎不起作用.它只是列出了地址下方的Multicell版本.

有人知道为什么会这样吗?

谢谢

推荐答案

tuto5.htm :

只使用:

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

因此,这意味着,添加一列之后,"位置 - 接头"应该是0您要寻找的可能是:

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

第二个通话后,您注意到1,这意味着下一个单元格在下面而不是之后(0会这样做).)

本文地址:https://www.itbaoku.cn/post/2090902.html

问题描述

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

推荐答案

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.)