简体   繁体   English

如果达到div高度,则将内容强制到新的打印页面上

[英]Force contents onto new print page if div height is reached

I have an HTML/CSS printable form that gets generates with content from a MySQL database using PHP. 我有一个HTML / CSS可打印形式,该形式使用PHP从MySQL数据库获取内容。 I am having a hard time figuring out how to get the middle content section to print another page if the content section is full. 我很难弄清楚如果内容部分已满,如何使中间内容部分打印另一页。 I need to keep the logo and order total section in place and only keep track of the middle content section. 我需要将徽标和订单总数部分保留在适当的位置,并且只跟踪中间内容部分。

Is there a way to do this with JavaScript? 有没有办法用JavaScript做到这一点? Or what is the best solution for this issue? 或针对此问题的最佳解决方案是什么?

Attached are screenshot markups to help see the issue. 随附屏幕截图标记,以帮助您发现问题。

http://timkipptutorials.com/images/linked/page1.png http://timkipptutorials.com/images/linked/page2.png http://timkipptutorials.com/images/linked/page1.png http://timkipptutorials.com/images/linked/page2.png

Printing headers and footers on every page is very difficult task, if you use div tags. 如果使用div标签,则在每个页面上打印页眉和页脚是非常困难的任务。 In my project I had searched almost full web and found that for printing the Headers and Footers every page you have to use tables and CSS rules, without using table and css you can't do printing of headers on every page. 在我的项目中,我几乎搜索了整个网络,发现要打印页眉和页脚,每个页面都必须使用表格和CSS规则,而不必使用table和CSS,就不能在每个页面上打印页眉。 I am providing you the code for doing so as under: 我正在为您提供执行此操作的代码,如下所示:

<style>
    @media screen{thead{display:none;}}
    @media print{thead{display:table-header-group; margin-bottom:2px;}}
    @page{margin-top:1cm;margin-left:1cm;margin-right:1cm;margin-bottom:1.5cm;}}
</style>

First CSS rule make that thead of table would not be displayed on the screen for the user and Second rule defines that during printing thead is displayed as table-header-group as this rule would show header on every page if you omit this headers would not print on each page and third rule is for maintaining the page margins from overlapping of header or footers and your html code would be as under: 第一条CSS规则使表格thead不会在用户的屏幕上显示,第二条规则定义在打印过程中thead显示为table-header-group,因为如果忽略此标头,该规则将在每个页面上显示标头在每页上打印,第三个规则是保持页眉或页脚重叠的页边距,并且您的html代码如下所示:

<table>
    <thead>
        <tr>
            <th>  <---  Your header text would be placed here    --->  </th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td>
                <--- Your printing text would be place here    ---> 
            </td>
        </tr>
    </tbody>
</table>

Last thing, I have tried thing code on IE, Safari, Firefox and Chrome and would like to tell you that on Chrome the header is printed only on 1st page. 最后一件事,我已经尝试在IE,Safari,Firefox和Chrome上使用事物代码,并想告诉您,在Chrome上,标题仅打印在第一页上。 I had also reported the bug many times but Chrome is not doing any thing about this issue. 我也曾多次报告该错误,但Chrome对此问题没有任何处理。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM