HTML Pagination

Hey All -

I'm taking a datatable, converting it to XML, transforming that with an XSL file, and then sending the HTML string to a WebBrowser control in a local WinForms application. Is there a way, via the HTMLDocument class perhaps, to control the pagination of the document For example, after the table occupies a certain height, the table concludes, and a new table, containing the header of the first table, is inserted and continues displaying the data The goal is to maintain a specific, printable page size so that each page contains the table header. I couldn't find any information regarding such a procedure via XSL, CSS or Javascript, so I'm hoping looping through the HTML elements and inserting a new table when necessary is a possibility.

Thanks in advance,




Answer this question

HTML Pagination

  • wenliang

    To control the pagination of a document As far as i know there is not such a way. I have on theory though.

    For example lets take the height of 1 page that is the specific size of a 1 page to print.

    PageMax = 1097pixels OR 11.43 inches OR 29.03 centimetres

    Then u will have to know how high each table row is. U can calculate this from the height of the Font u are using.

    FontHeight = 17px ( just an example )

    TableHeaderHeight = 20px

    RecordAmount = 100

    RecordsPerPage = Math.Floor((PageMax - TableHeaderHeight) / FontHeight)

    AmountOfPages = Math.Ceil((RecordAmount * FontHeight) / (PageMax - TableHeaderHeight))

    Then fill your table and when the amount of records placed inside this table is equal to RecordsPerPage you create a new table on the exact height of a new page. But THAT is really not easy to accomplish. Im not sure what the specific heights are that is exactly one page. I hope this help a bit!

    Good luck!



  • swimmer

    M. Dirksma -

    I've considered that approach, but it'd probably be a bit overwhelming if not impossible as the HTML contains additional elements of all sorts, not just a single table. Any other thoughts



  • HTML Pagination