简体   繁体   English

打印页面的分页符

[英]page-break-inside for a printable page

My application should support all modern browsers. 我的应用应支持所有现代浏览器。 The minimum required IE version is IE9. 所需的最低IE版本是IE9。

I have created a very basic page that can be printed. 我创建了一个可以打印的非常基本的页面。 On the page, there's a table. 在页面上,有一张桌子。 Each row contains some information about an article, including a barcode. 每行包含有关文章的一些信息,包括条形码。

When printing this page, the last row on the page is partially on one page, partially on the other. 打印此页面时,页面上的最后一行部分位于一页上,部分位于另一页上。 Worse, the barcode is split between two pages (the barcode is a number displayed in a special font). 更糟糕的是,条形码分为两页(条形码是以特殊字体显示的数字)。

I've had a look at page-break-inside . 我看了一下page-break-inside Here's my current code: 这是我目前的代码:

<div class="col-xs-12">
    <div class="row">
    <p class="text-center">Liste de prix</p>
        <table class="table borderless">
            <thead>
                <tr>
                    <th class="col-xs-4">Description</th>
                    <th class="col-xs-2">Prix / tige</th>
                    <th class="col-xs-2">Taille</th>
                    <th class="col-xs-4">Code</th>
                </tr>
            </thead>
            <tbody>
                <tr ng-repeat="article in vm.data.articles">
                    <div><td>{{ article.description }}</td></div>
                    <div><td>{{ article.unitPrice }}</td></div>
                    <div><td>{{ article.length }}</td></div>
                    <div><td style="font-family: barcode, arial; font-size: 225%;">{{ article.itemNumber | barcode }}</td></div>
                </tr>
            </tbody>
        </table>
    </div>
</div>

css: 

tr {
    page-break-inside: avoid;
}

(Don't mind the ugly inline style, that's just for testing purposes) (不要介意丑陋的内联样式,仅用于测试目的)

This does not do anything at all. 这根本不起作用。 I've had a look at similar questions and I've tried different solutions, like putting div's around the td's (that's why they're there) and using page-break-inside on these div's, using page-break-inside on the rows,... still, none of these solutions seem to do anything. 我已经看过类似的问题,我已经尝试了不同的解决方案,比如将div放在td(这就是为什么它们在那里)并在这些div上使用page-break-inside,使用page-break-inside行,...仍然,这些解决方案似乎都没有做任何事情。

I've discussed this issue with a colleage and he thinks there's nothing I can do to actually make this work. 我和一位大学讨论过这个问题,他认为我无法做到这一点。

Is this true? 这是真的? Am I doing something impossible? 我做的事情不可能吗? If not, why isn't this working? 如果没有,为什么这不起作用?

Using some css magic gives you the solution. 使用一些css魔法为您提供解决方案。

Like, 喜欢,

table tbody {
  position: fixed;
  bottom: 0;
  top: /* your desired value.*/ 
}

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

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