Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

fpdf alignment of cells

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

like image 800
sipher_z Avatar asked May 06 '11 13:05

sipher_z


1 Answers

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

like image 86
Joshua - Pendo Avatar answered Oct 22 '22 14:10

Joshua - Pendo