4

我有以下 cfdocument 代码:

<cfdocument format="pdf" orientation = "landscape" bookmark="Yes" marginleft=".25" marginright=".25" marginTop = ".75" marginbottom=".75" scale="90" localUrl="yes"> 
    <cfoutput>
        <cfdocumentsection name="Summary Page" marginleft=".25" marginright=".25" marginTop = "1.65" marginbottom="1" >
            <cfdocumentitem type="header">
                <center>
                    <table width="1000" height="200" cellpadding="3" cellspacing="0">
                        <tr><td>Header Page</td></tr>
                    </table>
                </center>
            </cfdocumentitem>

            <cfloop query="first_query">
                <cfquery name="getDetails" dbtype="query">
                    select * from first_query
                    where type= <cfqueryparam cfsqltype="cf_sql_varchar" value="#Type#">
                </cfquery>

                <cfsavecontent variable="trhead">
                    <tr class="bigbluecolor" style="text-align:center;">
                        <td width="6%">Term</td<
                    </tr>
                </cfsavecontent>
                #trhead#
                <cfloop query="getDetails">
                    <tr align="center">
                        <td width="6%">#Listfirst(TermYears,'.')# Years</td>
                    </tr>
                    <cfif getDetails.recordcount GT 6 AND getDetails.currentRow EQ 6>
                        <cfdocumentitem type="pagebreak"/>
                        #trhead#
                    </cfif>
                </cfloop>
            </table>
            </td></tr></table>
            </cfloop>
        </cfoutput>
    </cfdocumentsection>
</cfdocument>

但是,它不执行分页。它在顶部显示空白页面,然后它开始在任何它想要的地方中断。我希望我的内部循环在 4 条记录后中断,并且<TH>标题在第二页的开头再次重复。

trhead变量包含我用 包装的代码savecontent来显示它。

谁能解释我错过了什么?

4

1 回答 1

2

分页符的不可预测性是因为:

<cfif getDetails.recordcount GT 6 AND getDetails.currentRow EQ 6>

如果 getDetails 的记录少于 6 条,则该条件永远不会返回 true。另外,如果您有 12 条或更多记录,它不会返回 true。我建议这种方法。首先,将其添加到 first_query:

order by type

然后像这样构建您的内容:

<cfsavecontent variable="trhead">
<tr class="bigbluecolor" style="text-align:center;">
<td width="6%">Term</td>
</tr>
</cfsavecontent>

<cfoutput query="first_query">
other content goes here
<cfif currentRow mod 6 is 0>
<cfdocumentitem type="pagebreak"/>
#trhead#    
</cfif>
</cfoutput>
于 2016-05-14T16:52:50.970 回答