1

I made a html page and then I converted to PDF format through the library html2pdf.

code :

<?php 
      require('../admin/html2pdf/html2pdf.class.php');
        ob_start();
?>

 <page> 
    <page_header> 
<br>
<table>
    <tr class="headings"  style="background-color: #FFFFFF;">
             <th class="column-title">Home</th>
             <th class="column-title"><h3>web site</h3></div></th>
             <th class="column-title">Home</th>
    </tr>                              
</table>
</page_header> 
<page_footer> 
<div>
<TABLE BORDER = "1" id="table2">
    <TR style="background-color: #f2f2f2;">
        <TH COLSPAN=3 style="width: %;text-align: center;">Footer</TH>
        <TH COLSPAN=3 style="width: %;text-align: center">Copyright </TH>
        <TH COLSPAN=3 style="width: %;text-align: center">Copyright </TH>
    </TR>
    <TR>
        <TD >test</TD> <TD>test</TD><TD>test</TD> <TD>test</TD> <TD>test</TD> <TD>test</TD><TD>test</TD> <TD>test</TD> <TD>test</TD>
    </TR>

</TABLE>
</div>
</page_footer> 
</page> 

**Content :** 
<div style="" id="table1" class="content">  
<table>

    <tr class="headings"  style="background-color: #f2f2f2;">
                                    <th class="column-title" style="width: 0px">firstname</th>
                                    <th class="column-title" style="width: 80px">lastname</th>
                                    <th class="column-title" style="width: 80px">mail</th>
                                    <th class="column-title" style="width: 80px">phone</th>
                                    <th class="column-title" style="width: 80px">login</th>
                                    <th class="column-title" style="width: 80px">password</th>
                                    <th class="column-title" style="width: 80px">birthday</th>
   </tr>

                                    <tbody>


                                    <tr class="even pointer">
                                        <td class=" "><p style="">firstname1</p></td>
                                        <td class=" "><p style="">lastname1</p></td>
                                        <td class=" "><p style="">mail1</p></td>
                                        <td class=" "><p style="">phone1</p></td>
                                        <td class=" "><p style="">login1</p></td>
                                        <td class=" "><p style="">password1</p></td>
                                        <td class=" "><p style="">birthday1</p></td>
                                      </tr>
                              <tr class="even pointer">
                                        <td class=" "><p style="">firstname2</p></td>
                                        <td class=" "><p style="">lastname2</p></td>
                                        <td class=" "><p style="">mail2</p></td>
                                        <td class=" "><p style="">phone2</p></td>
                                        <td class=" "><p style="">login2</p></td>
                                        <td class=" "><p style="">password2</p></td>
                                        <td class=" "><p style="">birthday2</p></td>
                                      </tr>
                              <tr class="even pointer">
                                        <td class=" "><p style="">firstname3</p></td>
                                        <td class=" "><p style="">lastname3</p></td>
                                        <td class=" "><p style="">mail3</p></td>
                                        <td class=" "><p style="">phone3</p></td>
                                        <td class=" "><p style="">login3</p></td>
                                        <td class=" "><p style="">password3</p></td>
                                        <td class=" "><p style="">birthday3</p></td>
                                      </tr>
                             <tr class="even pointer">
                                        <td class=" "><p style="">firstname4</p></td>
                                        <td class=" "><p style="">lastname4</p></td>
                                        <td class=" "><p style="">mail4</p></td>
                                        <td class=" "><p style="">phone4</p></td>
                                        <td class=" "><p style="">login4</p></td>
                                        <td class=" "><p style="">password4</p></td>
                                        <td class=" "><p style="">birthday4</p></td>
                                      </tr>
                              <tr class="even pointer">
                                        <td class=" "><p style="">firstname5</p></td>
                                        <td class=" "><p style="">lastname5</p></td>
                                        <td class=" "><p style="">mail5</p></td>
                                        <td class=" "><p style="">phone5</p></td>
                                        <td class=" "><p style="">login5</p></td>
                                        <td class=" "><p style="">password5</p></td>
                                        <td class=" "><p style="">birthday5</p></td>
                                      </tr>
                              <tr class="even pointer">
                                        <td class=" "><p style="">firstname6</p></td>
                                        <td class=" "><p style="">lastname6</p></td>
                                        <td class=" "><p style="">mail6</p></td>
                                        <td class=" "><p style="">phone6</p></td>
                                        <td class=" "><p style="">login6</p></td>
                                        <td class=" "><p style="">password6</p></td>
                                        <td class=" "><p style="">birthday6</p></td>
                                      </tr>
                              <tr class="even pointer">
                                        <td class=" "><p style="">firstname7</p></td>
                                        <td class=" "><p style="">lastname7</p></td>
                                        <td class=" "><p style="">mail7</p></td>
                                        <td class=" "><p style="">phone7</p></td>
                                        <td class=" "><p style="">password7</p></td>
                                        <td class=" "><p style="">password7</p></td>
                                        <td class=" "><p style="">birthday7</p></td>
                                      </tr>
                              <tr class="even pointer">
                                        <td class=" "><p style="">firstname8</p></td>
                                        <td class=" "><p style="">lastname8</p></td>
                                        <td class=" "><p style="">mail8</p></td>
                                        <td class=" "><p style="">phone8</p></td>
                                        <td class=" "><p style="">login8</p></td>
                                        <td class=" "><p style="">password8</p></td>
                                        <td class=" "><p style="">birthday8</p></td>
                                      </tr>
                              <tr class="even pointer">
                                        <td class=" "><p style="">firstname9</p></td>
                                        <td class=" "><p style="">lastname9</p></td>
                                        <td class=" "><p style="">mail9</p></td>
                                        <td class=" "><p style="">phone9</p></td>
                                        <td class=" "><p style="">login9</p></td>
                                        <td class=" "><p style="">password9</p></td>
                                        <td class=" "><p style="">birthday9</p></td>
                              </tr>
                              <tr class="even pointer">
                                        <td class=" "><p style="">firstname10</p></td>
                                        <td class=" "><p style="">lastname10</p></td>
                                        <td class=" "><p style="">mail10</p></td>
                                        <td class=" "><p style="">phone10</p></td>
                                        <td class=" "><p style="">login10</p></td>
                                        <td class=" "><p style="">password10</p></td>
                                        <td class=" "><p style="">birthday10</p></td>
                              </tr>
                              <tr class="even pointer">
                                        <td class=" "><p style="">firstname11</p></td>
                                        <td class=" "><p style="">lastname11</p></td>
                                        <td class=" "><p style="">mail11</p></td>
                                        <td class=" "><p style="">phone11</p></td>
                                        <td class=" "><p style="">login11</p></td>
                                        <td class=" "><p style="">password11</p></td>
                                        <td class=" "><p style="">birthday11</p></td>
                              </tr>
                              <tr class="even pointer">
                                        <td class=" "><p style="">firstname12</p></td>
                                        <td class=" "><p style="">lastname12</p></td>
                                        <td class=" "><p style="">mail12</p></td>
                                        <td class=" "><p style="">phone12</p></td>
                                        <td class=" "><p style="">login12</p></td>
                                        <td class=" "><p style="">password12</p></td>
                                        <td class=" "><p style="">birthday12</p></td>
                              </tr>

                             <tr class="even pointer">
                                        <td class=" "><p style="">firstname13</p></td>
                                        <td class=" "><p style="">lastname13</p></td>
                                        <td class=" "><p style="">mail13</p></td>
                                        <td class=" "><p style="">phone13</p></td>
                                        <td class=" "><p style="">login3</p></td>
                                        <td class=" "><p style="">password13</p></td>
                                        <td class=" "><p style="">birthday13</p></td>
                              </tr>








                                </tbody>
</table>
</div>

<?php
    $content = ob_get_clean(); // récupère tout le contenu depuis ob_start()
    // ou $content = ob_get_clean() ça fonctionne également;
    $pdf = new HTML2PDF('P', 'A4', 'fr');
    $pdf->pdf->SetDisplayMode('fullpage');
    $pdf->writeHTML($content);
     ob_clean();
    $pdf->Output('test.pdf');
?>

it works very well at the conversion.but my problem in data display.there is a bad organization at the header and the footer.As you see in this picture :

enter image description here

johansson
  • 17
  • 2
  • 6

1 Answers1

0

Try with this css

        <style type="text/css">
            table { page-break-inside:auto }
            tr    { page-break-inside:avoid; page-break-after:auto }
            thead { display:table-header-group }
            tfoot { display:table-footer-group }
        </style>
Drone
  • 1,114
  • 1
  • 12
  • 31
  • it does not work with this css, the same result, there is a bad organization at the header and the footer – johansson Jun 28 '16 at 11:44
  • I would like to fix the header and footer and the content I would give free without mixing with the header or footer – johansson Jun 28 '16 at 11:46
  • check this: http://stackoverflow.com/a/1763683/5830872 if it works for you – Drone Jun 28 '16 at 11:50