python – Pisa在比萨(xhtml2pdf)只是重复最后一页

python – Pisa在比萨(xhtml2pdf)只是重复最后一页,第1张

概述我使用 Pisa生成PDF文件,其页面遵循通用格式. 我显然做错了,因为我生成PDF(来自命令行或来自python API)我只看到最后一页重复. 在下面的代码中运行比萨,我得到三个页面,每个页面都说“C星期三”,当我希望看到三个不同页面的“A Monday”,“B Tuesday”,“C Wednesday”. 我目前的比萨版本是XHTML2PDF / pisa 3.0.33(Build 201 我使用 Pisa生成pdf文件,其页面遵循通用格式.
我显然做错了,因为我生成pdf(来自命令行或来自python API)我只看到最后一页重复.

在下面的代码中运行比萨,我得到三个页面,每个页面都说“C星期三”,当我希望看到三个不同页面的“A Monday”,“B Tuesday”,“C Wednesday”.

我目前的比萨版本是xhtml2pdf / pisa 3.0.33(Build 2010-06-16)

<HTML><style>    /* 297 x 210 */@page {  size: a4 landscape;  margin: 1cm;  margin-bottom: 2.5cm;  @frame header {    -pdf-frame-content: headerContent;    background-color:black;    color:white;    top : 0cm;    margin-left: 0cm;    margin-right: 14.5cm;     height: 2.5cm;    wIDth: 14.9cm;  }  @frame lhs {    -pdf-frame-content: lhs;    background-color:white;    color:black;    top : 4.5cm;    margin-left: 0cm;    margin-right: 14.5cm;     height: 13.5cm;    wIDth: 14.9cm;  }  @frame footer {    -pdf-frame-content: footerContent;    color:black;    bottom: 1cm;    margin-left: 1cm;    margin-right: 24.5cm;     height: 1cm;  }}body {}#headerContent {    text-align: center;    background-color: black;    color: white;}h1 {    Font-size: 200%;}#lhs-table {    color:black;    text-align: center;    Font-size:600%;}.big {    Font-size:200%;    Font-style:italic;}.day {    text-align: center;    background-color: black;    color: white;    wIDth: 1.6cm;    height: 1.3cm;}#footerContent {    Font-size: 200%;}</style><body><div>  <div ID="headerContent">      <h1><br/>header<br/></h1>  </div>  <div ID="lhs">      <table ID="lhs-table" >                <tr>                    <td><span ><em>A</em></span></td>                </tr>            </table>    </div>  <div ID="footerContent">      <span  >Monday</span>  </div>  </div>    <pdf:nextpage /><div>  <div ID="headerContent">      <h1><br/>header<br/></h1>  </div>  <div ID="lhs">      <table ID="lhs-table" >                <tr>                    <td><span ><em>B</em></span></td>                </tr>            </table>    </div>  <div ID="footerContent">      <span  >Tuesday</span>  </div>  </div>    <pdf:nextpage /><div>  <div ID="headerContent">      <h1><br/>header<br/></h1>  </div>  <div ID="lhs">      <table ID="lhs-table" >                <tr>                    <td><span ><em>C</em></span></td>                </tr>            </table>    </div>  <div ID="footerContent">      <span  >Wednesday</span>  </div>  </div>    <pdf:nextpage /></body></HTML>
解决方法 试试Github https://github.com/chrisglass/xhtml2pdf的版本你的版本太旧而且没有维护.

关于您的问题,是解析器中的已知问题.尝试将标记放在自己的行上,如下所示:

<div ID="footer">     <pdf:pagenumber /></div>

第三次阅读后:

<body><div ID="header"></div> <div ID="content1>   content 1 </div> <pdf:nextpage /> <div ID="content2>     content 2 </div> <pdf:nextpage /> <div ID="content3>     content 3 </div> <pdf:nextpage /><div ID="footer"></div></body>

从您的代码中,您将重复每个内容的页眉和页脚.但是你已经将它们定义为标题框架(在每个页面上自动重复它们),因此解析器必须坚固.您还要为内容创建另一个静态框架,这不应该是.

因此,只有一个标题,一个页脚,使用< pdf:nextpage />创建许多内容.背后.

https://github.com/chrisglass/xhtml2pdf/blob/master/doc/usage.rst

也许我再次错过了你的错,因为我不知道你是如何产生这个HTML的.

总结

以上是内存溢出为你收集整理的python – Pisa在比萨(xhtml2pdf)只是重复最后一页全部内容,希望文章能够帮你解决python – Pisa在比萨(xhtml2pdf)只是重复最后一页所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/langs/1196755.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-03
下一篇 2022-06-03

发表评论

登录后才能评论

评论列表(0条)

保存