[英]Page break using CSS in HTML to create PDF
I have a custom tag <PBR/>
in HTML and I want to break page in PDF from this tag through CSS.我在 HTML 中有一个自定义标签<PBR/>
,我想通过 CSS 从这个标签打破 PDF 页面。 But I have no idea about this.但我对此一无所知。 How can I break pages: I have tried this in CSS but it is not working --我怎样才能打破页面:我已经在 CSS 中尝试过这个,但它不起作用——
pbr {
page-break-before: always;
}
I think the trouble comes in targeting custom HTML tags with CSS.我认为问题在于使用 CSS 定位自定义 HTML 标签。
I suggest using a class instead:我建议改用一个类:
.page { page-break-before:always; }
<pbr class="page" />
Create a custom class with the following properties and apply to your HTML element.创建具有以下属性的自定义类并应用于您的 HTML 元素。
<style>
.breakhere {
page-break-after: always;
display: block;
clear: both;
}
</style>
<div class="breakhere">...content...</div>
Note: Make sure your HTML doesn't contain overflow tag, as it will create problem with page-break tags.注意:确保您的 HTML 不包含溢出标记,因为它会导致分页标记出现问题。
Rotativa library provides a good option to return View as PDF. Rotativa 库提供了将视图返回为 PDF 的不错选择。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.