簡體   English   中英

Pisa在比薩(xhtml2pdf)重疊只是重復最后一頁

[英]Paginating in Pisa (xhtml2pdf) just repeats last page

我正在使用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 class="big"><em>A</em></span></td>
                </tr>
            </table>
    </div>

  <div id="footerContent">
      <span class="day" >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 class="big"><em>B</em></span></td>
                </tr>
            </table>
    </div>


  <div id="footerContent">
      <span class="day" >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 class="big"><em>C</em></span></td>
                </tr>
            </table>
    </div>

  <div id="footerContent">
      <span class="day" >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的。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM