即使在HTML& P中的双面打印的分页符CSS [英] Even page-break for double-sided printing in HTML & CSS

查看:671
本文介绍了即使在HTML& P中的双面打印的分页符CSS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有分页符为打印介质工作,快速 page-break-after:always 。我使用它们在单个批量打印作业中分隔多个报表。不幸的是,当打印作业是双面的时,分页可以使打印机在上一个报告的后面开始报告。



有任何方法强制分页到偶数页?或者,要检测某个元素将出现在哪个页面?

解决方案

CSS中没有内置功能

您可以尝试将每个报表包含在div中,然后使用某个元素像jquery一样,计算出div的 height ,以确定它是否在奇数页上结束。



如果它结束在一个奇怪的页面,然后注入一个空的div与你的page-break-after类后,以便它进给到下一页。



EDIT

显然,如果您知道您的页面在目标打印机上打印的dpi,这只会真的有效。




  • 72 dpi(网页)= 595 X 842像素

  • 300 dpi(打印)= 2480 X 3508像素
    (210mm X 297mm @ 300 dpi)

  • 600 dpi(打印)= 4960 X 7016像素



您需要在这里尝试一下标准打印机设置,看看什么对您/您的客户有效。如果有多个场景,您可以让他们从下拉列表中选择。



因此,您可以使用jquery检查div的像素高度,页面的像素高度,以查看div是否在奇数页或偶数页上结束 - 如果报告在奇数页上结束,则注入分页符。



d还需要知道用户将使用双面打印 - 因为你只需要这样做双面打印。


I've got page breaks working for print media with a quick page-break-after: always. I use these to separate multiple reports in a single batched print job. Unfortunately, when the print job is double-sided, the page break can cause the printer to start a report on the back of the previous report.

Is there any way to force a page break to an even page? Or, alternatively, to detect which page number a certain element will appear on?

解决方案

There's no built-in functionality in CSS for this.

An idea:
You could maybe try wrapping each of your reports in a div and then using something like jquery to work out the height of the div to figure out whether it ends on an odd page.

If it ends on an odd page, then inject an empty div with your page-break-after class after that so that it feeds to the next page.

EDIT
Obviously this will only really work if you know the dpi at which your page prints on your target printer. There's no magic answer that will just work for all scenarios.

  • 72 dpi (web) = 595 X 842 pixels
  • 300 dpi (print) = 2480 X 3508 pixels ("210mm X 297mm @ 300 dpi")
  • 600 dpi (print) = 4960 X 7016 pixels

You'd need to experiment a bit here with your standard printer settings to see what works for you/your client(s). If there are multiple scenarios, you could let them select from a drop-down.

So you'd use jquery to check the pixel height of the div, check it against the pixel height of the page to see if the div ends on an odd or even page - then inject the page break if the report ends on an odd page.

You'd also need to know upfront if the user will be using duplex printing - because you'd only need to do this for duplex printing.

这篇关于即使在HTML& P中的双面打印的分页符CSS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆