Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you make a table like this with FPDF using PHP?

How do you make a table like this with FPDF using PHP?

I can't seem to figure out how to do this with $this->Cell.

Table

like image 775
Heather McVay Avatar asked Nov 15 '12 22:11

Heather McVay


People also ask

How do you align a table in FPDF?

To center things on the page use SetLeftMargin to half of the difference between the page width, 210, and the total width of your columns, 153 which comes out to 28. Right after you create the instance of FPDF set the margin before starting a new page.

What is use of FPDF in PHP?

FPDF is a PHP class which allows generating PDF files with PHP code. It is free to use and it does not require any API keys. FPDF stands for Free PDF. It means that any kind of modification can be done in PDF files.

How do you use MultiCell in FPDF?

MultiCell( width of cell, height of each line, text content, border, alignment of the text, fill boolean). An example would be : $this ->MultiCell(25,6,”Here's some text for display”, 'LRT', 'L', 0); In the above example, the MultiCell width is set at 25 units that were specified in the initial call to FPDF.

How do I change the position of the cell in FPDF?

Try $pdf -> SetXY(100,100); // set the cursor at Y position 5 $pdf -> SetFont('Arial', 'I', 8); // set the font $pdf->Cell(0,0,'Descritpion'); It should creat a cell at 100,100 that extends all the way to the right margin of the pdf.


1 Answers

FPDF does not recognize rowspan or colspan. Here is a workaround that you can try, using empty cells and the border attribute for Cell.

$pdf->Cell(40,5,' ','LTR',0,'L',0);   // empty cell with left,top, and right borders
$pdf->Cell(50,5,'Words Here',1,0,'L',0);
$pdf->Cell(50,5,'Words Here',1,0,'L',0);
$pdf->Cell(40,5,'Words Here','LR',1,'C',0);  // cell with left and right borders
$pdf->Cell(50,5,'[ x ] abc',1,0,'L',0);
$pdf->Cell(50,5,'[ x ] checkbox1',1,0,'L',0);
$pdf->Cell(40,5,'','LBR',1,'L',0);   // empty cell with left,bottom, and right borders
$pdf->Cell(50,5,'[ x ] def',1,0,'L',0);
$pdf->Cell(50,5,'[ x ] checkbox2',1,0,'L',0);

and the result would be - fpdf table example

like image 103
Sean Avatar answered Nov 04 '22 16:11

Sean