[英]Force a new page using PdfBundle in Symfony2
I use the PdfBundle (PHPPdf) in Symfony2 and create the PDF using twig like this: 我在Symfony2中使用PdfBundle (PHPPdf)并使用这样的twig创建PDF:
<pdf>
<dynamic-page>
<placeholders>
<footer>
<div height="50px" width="100%">
<page-info font-size="9" font-type="helvetica" format="Page %s of %s" />
</div>
</footer>
</placeholders>
<div>
Some written text in the first page
</div>
<!-- Here I want to start always a second page -->
<div>
Some written text on the second page
</div>
</dynamic-page>
</pdf>
I want that the second text is always on a new page, but the numbering in the footer must continue. 我希望第二个文本始终在新页面上,但页脚中的编号必须继续。 When I start a new dynamic-page, there is a new page, but the numbering of the sites is gone. 当我开始一个新的动态页面时,有一个新页面,但网站的编号已经消失。
I found out the solution. 我找到了解决方案。 I misunderstood the information and thought page-break
is a attribute, but it is a tag. 我误解了信息和思想page-break
是一个属性,但它是一个标签。 So I must only set <page-break />
at the position I want to break the page. 所以我只能在我要打破页面的位置设置<page-break />
。
<pdf>
<dynamic-page>
<placeholders>
<footer>
<div height="50px" width="100%">
<page-info font-size="9" font-type="helvetica" format="Page %s of %s" />
</div>
</footer>
</placeholders>
<div>
Some written text in the first page
</div>
<page-break />
<div>
Some written text on the second page
</div>
</dynamic-page>
</pdf>
It is also important that the <page-break />
is a direct children of the <dynamic-page>
. <page-break />
是<dynamic-page>
的直接子<page-break />
也很重要。 It can't be in a div or table. 它不能在div或table中。 They must be closed to set a page break. 必须关闭它们才能设置分页符。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.