fpdf细胞比对 [英] fpdf alignment of cells

查看:70
本文介绍了fpdf细胞比对的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

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

I need to have 2 cells, like the following:

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

我尝试使用MultiCell(),但是没有运气.

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');

我认为我可以将"float"设置为左或右,这正是文档所说的,但这似乎行不通.它只是在地址下方而不是其右侧列出了Version多单元格.

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?

谢谢

推荐答案

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

只需使用:

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

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

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');

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

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

这篇关于fpdf细胞比对的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆