dongzhuo5185 2015-03-05 08:00
浏览 31
已采纳

在Symfony2中使用PdfBundle强制新页面

I use the PdfBundle (PHPPdf) in Symfony2 and create the PDF using twig like this:

<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.

  • 写回答

1条回答 默认 最新

  • duandong7980 2015-03-05 09:20
    关注

    I found out the solution. I misunderstood the information and thought page-break is a attribute, but it is a tag. So I must only set <page-break /> at the position I want to break the page.

    <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>. It can't be in a div or table. They must be closed to set a page break.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用
  • ¥15 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
  • ¥15 帮我写一个c++工程