温馨提示:本文翻译自stackoverflow.com,查看原文请点击:pdf - COLDFUSION: cfdocument and forcing a pagebreak
coldfusion pdf page-break cfdocument

pdf - COLDFUSION:cfdocument和强制分页符

发布于 2020-04-08 10:54:24

我正在ColdFusion中创建动态PDF,并且遇到“ pagebreak”问题。有问题的页面可能有1条记录,或多达60条以上的记录。每个记录显示在表的2行中。一些返回的记录正在页面之间拆分(第一行在第一页的末尾,第二行是下一页的第一行)。

显示的HTML中的示例记录:

<tr>
  <td>Title</td><td>Price</td>
  <td colspan="2">Description</td>
</tr>

每个客户的要求,我想显示= <9条记录每页

这是我尝试过的东西的精简样本:

<cfdocument format="PDF">
<cfoutput query = "sqllookup">
<cfset loopcount = loopcount + 1>
<cfif loopcount EQ '9'>
 <cfdocumentitem type="pagebreak" />
<cfelse>
<tr>
  <td>#Title#</td><td>#Price#</td>
  <td colspan="2">#Description#</td>
</tr>
</cfif>
</cfoutput>
</cfdocument>

这是行不通的,(它只隐藏第9条记录)我尝试了几种不同的想法,但目前感到困惑。我在看东西吗?

提前致谢。

ColdFusion MX7。(我还运行了文本截断问题的热修复程序 。http://kb2.adobe.com/cps/402/kb402093.html

查看更多

提问者
nope_four
被浏览
70
Ben Doom 2010-01-22 08:53

您要隐藏第9条记录,因为要在显示它和显示它之间进行选择:

if 9th record
    break page
else
    show record
end if

您想要的更像是:

<cfoutput query = "sqllookup">
    <!--- this is the 9th row, because 9 mod 9 is 0 --->
    <cfif not sqllookup.currentrow mod 9>
        <cfdocumentitem type="pagebreak" />
    </cfif>
    <tr>
        <td>#Title#</td><td>#Price#</td>
        <td colspan="2">#Description#</td>
    </tr>
</cfoutput>