Generate page break report in print

Asked

Viewed 1,536 times

1

I have a form that generates a list I need to print.

That list, sometimes I will print only a few pages, so on each page, I need to have some data:

  • page number
  • balance from the previous page
  • caption header
  • records
  • final balance (last page)

Example:

rel


In research, I found the DOMPDF to print of html to PDF, but I don’t know if it would be the best option, and if it was, how does the break.

I would at least like a direction where to start, what is possible or not to do.

1 answer

1

To repeat information on all printed pages, it is possible to use the tag THEAD.

Documentation and examples of the THEAD tag

Works normal in firefox/Chrome, but to do the THEAD repeat the data also in IE old it is necessary to have the css/hack below together on the page:

thead {display: table-header-group;}

To make the impression break page at a certain point, da para usar o css page-break-after along with the media print, defining page-break for some element of your html.

Example:

@media print {
    footer {page-break-after: always;}
}

More page-break-after details

Example of page-break-after running online:

<html>
    <head></head>
    <body>

        <table style="page-break-after: always">
            <tr>
                <td>asdsadsd</td>
            </tr>
        </table>
        <br/><br/>
        <div>
            qqqqqq
        </div>

    </body>
</html>

  • res, is it possible not to use CSS? It works inline page-break-after: always;?

  • I don’t know otherwise than CSS, otherwise it would have to be programmatically, within a FOR or something like, kind of "manual".

  • Yes, it works online, I added an executable example, that example in an html of his, when trying to print in firefox left the table in one page and div in another

  • So, but I’ll loop it. I’ll have to do a record counter and do an if to add the break per class in the tag. If I had something simpler, I wouldn’t even need the CSS to break. I’ll go into it. But thanks for now!

  • I did some tests and did not understand some things. Why use the THEAD, TBODY whether I will break into several tables my records <table style="page-break-after: always"> ? In test I did, the break does not work if not inserted directly into the <table>... that’s right?

Browser other questions tagged

You are not signed in. Login or sign up in order to post.