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
.
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.
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.
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.
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.
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 -
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With