Fpdf Tables: Splitting / Merging Cells
I am trying to create a PDF that contains a table with split / merged cells looking like this:
Cell | Cell | Cell
Cell | C1 | C2 | Cell
| C1 | C2 | Cell
I am using fpdf and referenced the multicore script file table I used earlier in similar pdf files. I have looked at the code and cant figure out how to make the cells split or merge according to what I need. Does anyone know how to do this?
+2
lmg
source
to share
1 answer
Just do it manually so that the cell width becomes the sum of both merged cells.
As per your example:
$column_widths = ["50","50","50","50"];
// First row.
$pdf->Cell($column_widths[0], 5, "Cell", "", 0, "C", false);
$pdf->Cell($column_widths[1] + $column_widths[2], 5, "Cell", "", 0, "C", false);
$pdf->Cell($column_widths[3], 5, "Cell", "", 0, "C", false);
// Second row.
$pdf->Cell($column_widths[0], 5, "Cell", "", 0, "C", false);
$pdf->Cell($column_widths[1], 5, "C1", "", 0, "C", false);
$pdf->Cell($column_widths[2], 5, "C2", "", 0, "C", false);
$pdf->Cell($column_widths[3], 5, "Cell", "", 0, "C", false);
// Third row.
$pdf->Cell($column_widths[0], 5, "", "", 0, "C", false);
$pdf->Cell($column_widths[1], 5, "C1", "", 0, "C", false);
$pdf->Cell($column_widths[2], 5, "C2", "", 0, "C", false);
$pdf->Cell($column_widths[3], 5, "Cell", "", 0, "C", false);
Or something like that.
+3
source to share