2017-03-15 48 views
1

我正在使用cfdocument將表格內容保存爲PDF。我正在使用cfoutput爲查詢中的每一行生成一個。每x行,我想強制分頁符,插入表格的標題行,並繼續循環查詢。發生什麼事情是在表和表之間插入了幾個分頁符,並且它完全忽略了分頁符的位置。標籤不應該在桌子內工作嗎?我的代碼如下:CFdocumentitem Pagebreak不起作用

<cfdocument format="pdf" orientation="landscape"> 
    <h1>Cumulative Daily Report</h1> 
     <table id="displayTable" cellspacing="0"> 
      <tr> 
       <th>Specialist</th> 
       <th>Asmnts</th> 
       <th>Avg Length</th> 
       <th>Day 2 Returns</th> 
       <th>QPRs</th> 
       <th>NCAs</th> 
       <th>Asmnts</th> 
       <th>Avg Length</th> 
       <th>Day 2 Returns</th> 
       <th>QPRs</th> 
       <th>NCAs</th> 
       <th># of Days</th> 
       <th>AEU/th> 
       <th>Asmnts</th> 
       <th>QPRs</th> 
       <th>NCAs</th> 
       <th># of Days</th> 
       <th></th> 
      </tr> 
      <cfoutput query="qryDisplay"> 
        <cfif qryDisplay.currentRow MOD (rowsPerPage + 1) EQ 0> 
         <cfdocumentitem type="pagebreak"></cfdocumentitem>   <tr> 
          <td colspan="18">Column Header Row here</td> 
         </tr> 
        </cfif> 
       <tr> 
        <td>#SpecialistName#</td> 
        <td>#numberFormat(nSixNumAssess, ",")#</td> 
        <td>#numberFormat(nSixAvgLength, ",")#</td> 
        <td>#numberFormat(nSixDay2Rets, ",")#</td> 
        <td>#numberFormat(nSixQPRs, ",")#</td> 
        <td>#numberFormat(nSixNCAs, "_._")#</td> 
        <td class="contrastBG">#numberFormat(nRtscNumAssess, ",")#</td> 
        <td class="contrastBG">#numberFormat(nRtscAvgLength, ",")#</td> 
        <td class="contrastBG">#numberFormat(nRtscDay2Rets, ",")#</td> 
        <td class="contrastBG">#numberFormat(nRtscQPRs, ",")#</td> 
        <td class="contrastBG">#numberFormat(nRtscNCAs, "_._")#</td> 
        <td>#numberFormat(nSixNumDaysWorked, ",")#</td> 
        <td class="bold">#numberFormat(nSixAEU,"_.__")#</td> 
        <td class="contrastBG">#numberFormat(nWecareNumAssess, ",")#</td> 
        <td class="contrastBG">#numberFormat(nWecareQPRs, ",")#</td> 
        <td class="contrastBG">#numberFormat(nWecareNCAs,"_._")#</td> 
        <td class="contrastBG">#numberFormat(nWecareNumDaysWorked, ",")#</td> 
        <td class="contrastBG bold rightBorder">#numberFormat(nWecareAEU,"_.__")#</td> 
       </tr> 
      </cfoutput> 
     </table> 
</cfdocument> 
+0

我不認爲這是可能的。嘗試使用像wkhtmltopdf這樣的第三方軟件。 –

+0

你在使用什麼版本的ColdFusion? –

+0

使用CF10 – Cmaso

回答

1

問題是你正試圖在表格中打破。 cfdocument的html渲染器無法處理該問題。

要解決這個問題,您必須循環使用TR,併爲每個創建的頁面添加開始/關閉表標記(以及標題行)。

在循環開始之前記住開始表標記和標題行,然後關閉表。

1

我發現,如果它實際放置在td中,該分頁工作。所以我最終創建了一個分頁符,並在每行x中插入一個標題行,其中x是用戶輸入的數字,默認爲15.因此:

<cfoutput query="qryDisplay"> 
       <cfif qryDisplay.currentRow MOD (form.rowsPerPDFPage + 1) EQ 0> 
        <!---do a pagebreak and insert header rows. Pagebreak must be inside the td tag to work---> 
        <tr> 
         <td colspan="18" class="noBorder"> 
          <cfdocumentItem type="pagebreak" /> 
         </td> 
        </tr> 
        <tr> 
         <td class="bottomBorderOnly"></td> 
         <th class="topBorder leftBorder" colspan="5">Sixteenth Street</th> 
         <th class="topBorder"colspan="5">RTSC/SRT</th> 
         <th class="topBorder"colspan="2">16th/RTSC</th> 
         <th class="topBorder rightBorder" colspan="5">WeCARE</th> 
        </tr>