我在Symfony2中使用PdfBundle(PHPPdf),并使用类似于的树枝创建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>
我希望第二个文本总是在新页面上,但页脚中的编号必须继续。当我启动一个新的动态页面时,会有一个新页面,但网站的编号已经消失。
我找到了解决方案。我误解了信息,认为page-break
是一个属性,但它是一个标签。所以我必须只将<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>
同样重要的是,<page-break />
是<dynamic-page>
的直接子代。它不能在div或表中。必须关闭它们才能设置分页符。