Skip to main content
Participant
October 14, 2009
Answered

cfdocument

  • October 14, 2009
  • 1 reply
  • 1153 views

I am having a heck of a time trying to work with page breaks using <cfdocument>. I have a query that I loop over and it generates some html <table> with data from the query in the html <td>'s. The problem is the page just breaks off and continues on the next page, it essentially just cuts my table wherever the page break occurs.

I have tried css, adjusting the margins,  cfdocumentitem pagebreak, etc...to no avail.

I am using version  8,0,0,176276

Any suggestion would be greatly appreciated.

    This topic has been closed for replies.
    Correct answer Leonard_B

    Hey There,

    Try something like this:

    Repeat additional page code below to cover the query output. You can

    add enough additional page code to account for future output data. Like

    if current output requires 5 pages, you could code for 8 pages, giving you

    a 3 page buffer before having to add more additional page code.

    Leonard B

    <=== Code below ===>

    <cfdocument>

    <table>
    <tbody>
    <cfoutput query="qname" maxrows="[enter max rows to display per page]" startrow="1">
    <tr>
        <td>
        <!---  Insert output --->
        </td>
    </tr>
    </cfoutput>
    </tbody>
    </table>

    <!--- Additional page (2) --->

    <cfif qname.recordcount gt 25>
    <cfdocumentitem type="pagebreak" />

    <table>
    <tbody>
    <cfoutput query="qname" maxrows="[enter max rows to display per page]" startrow="[enter start row for page]">
    <tr>
        <td>
        <!---  Insert output --->
        </td>
    </tr>
    </cfoutput>
    </tbody>
    </table>

    </cfif>

    <!--- Additional page (3) --->

    <cfif qname.recordcount gt 50>
    <cfdocumentitem type="pagebreak" />

    <table>
    <tbody>
    <cfoutput query="qname" maxrows="[enter max rows to display per page]" startrow="[enter start row for page]">
    <tr>
         <td>
         <!---  Insert output --->
         </td>
    </tr>
    </cfoutput>
    </tbody>
    </table>

    </cfif>

    </cfdocument>

    1 reply

    Leonard_BCorrect answer
    Inspiring
    October 14, 2009

    Hey There,

    Try something like this:

    Repeat additional page code below to cover the query output. You can

    add enough additional page code to account for future output data. Like

    if current output requires 5 pages, you could code for 8 pages, giving you

    a 3 page buffer before having to add more additional page code.

    Leonard B

    <=== Code below ===>

    <cfdocument>

    <table>
    <tbody>
    <cfoutput query="qname" maxrows="[enter max rows to display per page]" startrow="1">
    <tr>
        <td>
        <!---  Insert output --->
        </td>
    </tr>
    </cfoutput>
    </tbody>
    </table>

    <!--- Additional page (2) --->

    <cfif qname.recordcount gt 25>
    <cfdocumentitem type="pagebreak" />

    <table>
    <tbody>
    <cfoutput query="qname" maxrows="[enter max rows to display per page]" startrow="[enter start row for page]">
    <tr>
        <td>
        <!---  Insert output --->
        </td>
    </tr>
    </cfoutput>
    </tbody>
    </table>

    </cfif>

    <!--- Additional page (3) --->

    <cfif qname.recordcount gt 50>
    <cfdocumentitem type="pagebreak" />

    <table>
    <tbody>
    <cfoutput query="qname" maxrows="[enter max rows to display per page]" startrow="[enter start row for page]">
    <tr>
         <td>
         <!---  Insert output --->
         </td>
    </tr>
    </cfoutput>
    </tbody>
    </table>

    </cfif>

    </cfdocument>

    Participant
    October 15, 2009

    Thank you for responding so quickly. I did what you suggested, but the pagebreak is not working as intended, instead it creates a gap (about 3 lines) between output queries.

    Thanks...