Using CSS and/or jQuery for Printed Pages with Page Breaks

前端 未结 5 1391
灰色年华
灰色年华 2020-12-31 17:50

I have a dynamically generated html page which is designed to be printed.

I would like to create page breaks based upon div sections - where any given div - if it DO

5条回答
  •  佛祖请我去吃肉
    2020-12-31 18:27

    The point of print-pagination, in my mind, is to not split things badly. And usually, what you want not to split badly most often is tabular data. So this is an approach that assumes you have changed the

    's into table formatting and grouped the sets of rows that should not be split into groupings.

    We want to mark headers and footers for the code to find, and we do not necessarily want them to appear right where they are described

    This invokes itself at page load, but could instead be called right before printing.

    
    

    We lay out the table to be paginated like this.

    
        
                PAGE ONE HEADER
            
                LATER PAGE HEADER (IF RELEVANT)
            
                ROW GROUP 1
            
                ROW GROUP N
            
               FOOTER
            

    We scan over the 's and stuff a footer and a header before any element that is destined to break across the end of a page.

    We mark headers and footers with css classes and keep track of the possibility of changing headers and footers by putting them at the locations in the row flow where they need to change, but keeping them invisible with another css class.

    Annoyingly some implementations of page breaking only apply to strictly "block" elements, so it is not defined on tbody. Therefore I have applied it to a

    tag class appended to each page table.

提交回复
热议问题