Right now when I use a cell with text, it all stays on one line. I know I could use the write function, but I want to be able to specify the height and width.
This is what I have now, but as I said the text does not wrap to stay in the dimensions:
$pdf->Cell( 200, 40, $reportSubtitle, 1, 1 );
$w_w=$c_height/3; example:if you want to wrap a word with 3 line. and the cell height is 9 so 9/3=3. first w_w line will be echo in height 3 and next line is echoed in height 6 and next line will be in height 9.
Using this is pretty simple. You just call the WordWrap() extension method and pass it the column width you'd like. This will word wrap the text clamping to 10 characters in width.
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.
The MultiCell
is used for print text with multiple lines. It has the same atributes of Cell
except for ln
and link
.
$pdf->MultiCell( 200, 40, $reportSubtitle, 1);
What multiCell does is to spread the given text into multiple cells, this means that the second parameter defines the height of each line (individual cell) and not the height of all cells (collectively).
MultiCell(float w, float h, string txt [, mixed border [, string align [, boolean fill]]])
You can read the full documentation here.
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