Reputation: 151
I am generating a report that has many different tables to display different data sets. Often the tables will flow into a second or third page, Does anyone know how to make the table headers repeat?
I cannot use the record count to determine when to insert the header information as the data is of random length so on record with wrapped text could consume 10 lines on the page. I have tried storing the table header as a variable and using , but it displays the last table's header on the top of each page.
Here is some sample code to illustrate the problem:
<cfoutput>
<cfdocument format="PDF" name="TestDetailReport" marginBottom = "1" marginLeft = ".3" marginRight = ".3" marginTop = ".5" orientation="landscape">
<cfdocumentsection name = "TA Overview" >
<cfdocumentitem type = "header">
<table width="100%">
<tr>
<td width="40%">Generated by:</td>
<td width="60%" align="left">cfdocumentitem type = "header"</td>
</tr>
</table>
</cfdocumentitem>
<!--- There will be several sections like this, each with thier own header --->
<body style="margin: 0px">
<table style="width:100%;">
<!-- table header to be repeated on each PDF page -->
<thead align="left" style="display: table-header-group">
<tr>
<td colspan="2" style=" text-align:center;color:red">Make the header of this section repeat when the table goes into the next page</td>
</tr>
<tr>
<td style="text-align:center;color:red">Row Number</td>
<td style="text-align:center;color:red">This column contains text of random length</td>
</tr>
</thead>
<!-- table body -->
<tbody>
<cfloop from="1" to="50" index="Index">
<tr style="border-bottom:thin;">
<td>Row #Index#</td>
<td><cfloop from="0" to="#RandRange(1, 50)#" index="randomText">#Index# blah </cfloop></td>
</tr>
</cfloop>
</tbody>
</table>
</body>
<cfdocumentitem type = "footer">
<table width="100%">
<tr>
<td width="12%">Generated by:</td>
<td width="13%" align="left">#cgi.auth_user#</td>
<td width="50%" rowspan="3" align="left">img src="file:///#ExpandPath('logo.gif')#"</td>
<td width="25%" rowspan="3" align="justify">Printed Copy as Part of Prepbook is a Controlled Document. All Other Copies are Uncontrolled.</td>
</tr>
<tr>
<td>Date:</td>
<td align="left">#DateFormat(now(), "medium")#</td>
<!--- <td align="right"></td> --->
</tr>
<tr>
<td>Page:</td>
<td align="left">#cfdocument.currentpagenumber# of #cfdocument.totalpagecount#</td>
<!--- <td align="right"></td> --->
</tr>
</table>
</cfdocumentitem>
</cfdocumentsection>
</cfdocument>
Upvotes: 2
Views: 3080
Reputation: 3396
@BTThomas yes we can done this by using CSS
table { -fs-table-paginate: paginate !important; }
Table header exists even pdf page changes like this
Upvotes: 1
Reputation: 595
Few Solutions
If you decide to go with Report Builder Scenario, which is probably the best for you. here is what you have to do:
STEP 1 -Create cfr(ColdFsuion Report Builder template file) in coldFusion Builder for each different table you have in report. This is pretty simple. Here are some docs
STEP 2 Generate temporary pdf for each "table" using cfreport and then use ddx to merge this files and add/design headers and footers of the report
Upvotes: 1
Reputation: 76
I don't think the PDF generator is clever enough to achieve this.
I agree with James A to use enter code here CFDocItem to control WHEN the page breaks occur - it's the only way around it I've ever found.
In the past, we've allowed the user to specify themselves when the page breaks will occur. This works for us because the page breaks they create will still work no matter what data is output (because it's statistical, and its size doesnt change much - unlike large amounts of text).
One suggestion (though could be the worst idea ever) could be to hack the PDF header to contain your table headers [dodges things being thrown]
Upvotes: 1
Reputation: 11120
<cfdocumentitem type= "pagebreak>
provides the ability to separate document into pages. I suspect that you will have to re-output your table header each and every time.
See:
http://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WSc3ff6d0ea77859461172e0811cbec22c24-7758.html
Upvotes: 1