0

I am trying to do a page grouping/ page break in TCPDF from the recordsets i get from database by grouping by sql statement. Each 'group by' recordsets from database should start from a new page in PDF. I tried looking for the examples given at TCPDF website but they are more static pages and not the dynamic. Is there any way around we can do it?

Thanks in advance

Kunal Parekh
  • 380
  • 6
  • 24

1 Answers1

0

It is very easy Sarah.

When you doing the While loop to fetch the recordsets delcare it like:

<?php 

            $pb = 0; //pagebreak counter
            do { 

                if ($pb != $row['yourforiegnkey']){?> 
// make sure you close your tag for php above here
                    <br pagebreak="true"/>
                    <?php // and open your php tag again here, or else it will not go to the next page
                    $pb = $row['yourforiegnkey'];

                }

                else {
                echo $row['yourforiegnkey'] . "<br>";   
                }

?>

Hope this works!!!

Kunal Parekh
  • 380
  • 6
  • 24