need a good method to Page break and add Header

Viewed 96

I am using itextsharp library.I design an HTML page and convert to PDF .
in that case some table are not split perfectly and row also not split correctly.
I tried to put a comment in the HTML code writing based on the font how many rows the page can contains, then after reaching the limit i just add another page,
this works but doesnt seems a professional way to fix this.

After a search i found many discussions using this code

<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>

But, what if i need to add a header on each page?
thanks

1 Answers

If you don't want to use events, a tricky method is to use this css style:

table.hrepeat {
  repeat-header: yes;
}

and wrap all your content inside an html table adding header to repeat as head of the table.

Example:

    <!DOCTYPE html>
    <head>
    <style type="text/css">
      table.hrepeat {repeat-header: yes;}
    </style>
    </head>
    <body>
      <table class="hrepeat">
        <thead>
          <tr>
            <th>Header on each page</th>
          </tr>
        </thead>
        <tbody>
           ....
        </tbody>
      </table>
    </body>
Related