Reputation: 1113
I'm using cfdocument to save table content to PDF. I'm using cfoutput to generate a for every row in the query. Every x rows, I want to force a page break, insert the table's header row, and continue looping through the query. What's happening instead is that several page breaks are inserted between the and the table, and it completely ignores where the pagebreak should be. Shouldn't the tag work inside a table? My code below:
<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>
Upvotes: 1
Views: 657
Reputation: 1
The cfdocumentitem type="pagebreak" is not working inside a table,so close the table first,then put and open again same table;
</table>
<cfdocumentitem type="pagebreak">
<table>
Upvotes: 0
Reputation: 1113
I found that thepagebreak works if it's actually placed inside a td. So I ended up creating a page break and inserting a header row into the document every x rows, where x is a number input by the user and defaults to 15. So:
<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>
Upvotes: 1
Reputation: 2019
The problem is you're trying to break within a table. The html renderer for cfdocument can't handle that.
To fix this you'll have to loop with TRs, and put opening/closing table tags (and the header row) for each page created.
Remember before the loop to start with the opening table tag and header row, and to close the table afterwards.
Upvotes: 2