却找到相当容易的方法(在头痛后)来做这件事。
在项目上方放置浮动位置标记 div, 以便您获得起始坐标( 我称之为 ID 项) 。
然后用数据最高层次的 divs 和等级 < code> 无法破解的 。
还包含强制分页符的等级 :
.page-breaker {
display: block;
clear: both;
page-break-after: always;
}
然后,在
<script>
// Very top of items
var current_top = $( #item_top ).offset().top;
// Check distance from top of page to bottom of item
// If greater than page size put page break and headers before
// Reset top of page to top of item.
$( .unbreakable_section ).each(function(index) {
var item_bottom = $(this).offset().top + $(this).outerHeight(true);
if ((item_bottom - current_top) > 1250) {
$(this).before("<div class= page-breaker ></div>");
$(this).before("Headings Div here");
current_top = $(this).offset().top - 48; // item - header height
}
});
</script>
这将测量自上页分页以来的垂直空格, 并新建一页, 如果空格超过页面高度, 则在页面上方放置一个页眉 。 ( 大约( 1250 ), 这对我来说足够接近 -- 页面上有页脚, 因此高度可能随您的设置而变化 ) 。
测试了100页文件的预期效果。