Search code examples
pdfcoldfusionpage-breakcfdocument

Force a page break and including headers when using cfdocument?


I'm generating a <table> and converting it to PDF using <cfdocument>. I would like to include the table header on the new page when it runs over. This is around every 30th line.

Here is my current code. The <cfif> is supposed to force a break at every new line. However, all it seems to do is create 4 blank pages with the content at the bottom, formatted the same as it was before

<cfloop query="One">

    <cfif not(One.currentrow MOD 30)>
        <cfdocumentitem type="pagebreak" />
        <th>Contact Name</th>
     </cfif>

     <cfoutput> 
        #One.contactName# 
     </cfoutput>

Solution

  • Fixed. Here is what I used to get my header on every page. Further note, if you need to adjust the document header size, then include margintop="2.2" in your main tag and adjust to taste.

     <cfdocumentitem type="header" evalAtPrint="true" > 
            <td>Contact Name</td>
     </cfdocumentitem>