Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>bmb is on the right track. Here is a little more detailed solution. </p> <p>There are a number of different ways to do this, but you'll have to make some decisions based on what you want. If you have rows that may take up half the page, then this probably isn't going to work the best for you, but if your rows are typically about 2 - 5 lines long then this is a good method. </p> <p>Because my first cell in the row is a multiple lined cell (MultiCell in FPDF speak) in my table, the rows are of dynamic height based on this first cell. So I figure out how high the row is going to be based on the string width and the width of the cell and then compare that with the room left on the page, based on the current Y position, the page height and the bottom margin:</p> <pre class="lang-php prettyprint-override"><code>while ($row = mysql_fetch_array($result)) { // multicell content $description = $row['desciption']; // get column width from a column widths array $column_width = $column_widths['description']; $number_of_lines = ceil( $pdf-&gt;GetStringWidth($description) / ($column_width - 1) ); // I subtracted one from column width as a kind of cell padding // height of resulting cell $cell_height = 5 + 1; // I have my cells at a height of five so set to six for a padding $height_of_cell = ceil( $number_of_lines * $cell_height ); // set page constants $page_height = 279.4; // mm (portrait letter) $bottom_margin = 20; // mm // mm until end of page (less bottom margin of 20mm) $space_left = $page_height - $pdf.GetY(); // space left on page $space_left -= $bottom_margin; // less the bottom margin // test if height of cell is greater than space left if ( $height_of_cell &gt;= $space_left) { $pdf-&gt;Ln(); $pdf-&gt;AddPage(); // page break. $pdf-&gt;Cell(100,5,'','B',2); // this creates a blank row for formatting reasons } // ... // actual creation of pdf stuff // ... } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload