COLDFUSION:cfdocument 并强制分页 [英] COLDFUSION: cfdocument and forcing a pagebreak

查看:18
本文介绍了COLDFUSION:cfdocument 并强制分页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am creating a dynamic PDF in ColdFusion and having an issue with "pagebreak". The page in question could have 1 record, or up to 60+ records. Each record is displayed in 2 rows of a table. Some of the returned records are being split between pages (first row is at the end of page one, the second row is the top row of the next).

显示的 HTML 中的示例记录:

A sample record in displayed HTML:

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

根据客户要求,我正在尝试显示 =<每页 9 条记录.

这是我尝试过的一个简化示例:

Here is a dumbed down sample of something I have tried:

<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 条记录).我尝试了几种不同的想法,目前我很困惑.我是不是在看东西?

This does not work, (it only hides the 9th record). I have tried several different ideas, and I am currently stumped. Am I over looking something?

提前致谢.

ColdFusion MX 7.(我还针对文本截断问题运行了热修复程序.http://kb2.adobe.com/cps/402/kb402093.html)

推荐答案

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

You are hiding the 9th record because you are choosing between displaying it and showing it:

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>

这篇关于COLDFUSION:cfdocument 并强制分页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆