2

我正在生成一个报告,其中包含许多不同的表格来显示不同的数据集。通常表格会流入第二页或第三页,有谁知道如何使表格标题重复?

我无法使用记录计数来确定何时插入标题信息,因为数据是随机长度的,因此带有包装文本的记录可能会占用页面上的 10 行。我尝试将表头存储为变量并使用 ,但它会在每一页的顶部显示最后一个表的标题。

下面是一些示例代码来说明问题:

<cfoutput>
<cfdocument format="PDF" name="TestDetailReport" marginBottom = "1" marginLeft = ".3" marginRight = ".3" marginTop = ".5" orientation="landscape">
    <cfdocumentsection name = "TA Overview" >
        <cfdocumentitem type = "header">
            <table width="100%">
                <tr>
                    <td width="40%">Generated by:</td>
                    <td width="60%" align="left">cfdocumentitem type = "header"</td>
                </tr>
            </table>
        </cfdocumentitem>

        <!--- There will be several sections like this, each with thier own header --->
        <body style="margin: 0px">
            <table style="width:100%;">
                <!-- table header to be repeated on each PDF page -->
                <thead align="left" style="display: table-header-group">
                    <tr>
                        <td colspan="2" style=" text-align:center;color:red">Make the header of this section repeat when the table goes into the next page</td>
                    </tr>
                    <tr>
                        <td style="text-align:center;color:red">Row Number</td>
                        <td style="text-align:center;color:red">This column contains text of random length</td>
                    </tr>
                </thead>
                <!-- table body -->
                <tbody>
                    <cfloop from="1" to="50" index="Index">
                    <tr style="border-bottom:thin;">
                        <td>Row #Index#</td>
                        <td><cfloop from="0" to="#RandRange(1, 50)#" index="randomText">#Index# blah </cfloop></td>
                    </tr>
                    </cfloop>
                </tbody>
            </table>
        </body>

        <cfdocumentitem type = "footer">
            <table width="100%">
                <tr>
                    <td width="12%">Generated by:</td>
                    <td width="13%" align="left">#cgi.auth_user#</td>
                    <td width="50%" rowspan="3" align="left">img src="file:///#ExpandPath('logo.gif')#"</td>
                    <td width="25%" rowspan="3" align="justify">Printed Copy as Part of Prepbook is a Controlled Document. All Other Copies are Uncontrolled.</td>
                </tr>
                <tr>
                    <td>Date:</td>
                    <td align="left">#DateFormat(now(), "medium")#</td>
                    <!--- <td align="right"></td> --->
                </tr>
                <tr>
                    <td>Page:</td>
                    <td align="left">#cfdocument.currentpagenumber# of #cfdocument.totalpagecount#</td>
                    <!--- <td align="right"></td> --->
                </tr>

            </table>
        </cfdocumentitem>
    </cfdocumentsection>
</cfdocument>

4

3 回答 3

1

我不认为 PDF 生成器足够聪明来实现这一点。

我同意 James A 在此处使用输入代码 CFDocItem 来控制何时发生分页符 - 这是我找到的唯一解决方法。

过去,我们允许用户自行指定何时发生分页符。这对我们有用,因为无论输出什么数据,他们创建的分页符仍然有效(因为它是统计的,并且它的大小变化不大 - 不像大量的文本)。

一个建议(尽管可能是有史以来最糟糕的想法)可能是破解 PDF 标题以包含您的表格标题 [躲避被抛出的东西]

于 2014-03-10T10:27:44.053 回答
1

<cfdocumentitem type= "pagebreak>提供将文档分成页面的能力。我怀疑您每次都必须重新输出表格标题。

看:

http://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WSc3ff6d0ea77859461172e0811cbec22c24-7758.html

于 2014-03-08T04:58:03.137 回答
1

几个解决方案

  • 如果表中有超过 n 条记录,则创建一个将再次输出表头的逻辑。这不是一个好的解决方案,我总是会跳过使用 cfdocument 来编写我的 pdf 报告,但它可以做到。您将面临 cfdocument 中的 html 问题。
  • 更好的解决方案是使用 ColdFusion Builder。
  • 也许最好的解决方案是使用ColdFusion Report Builder 替代方案, 但设置和运行所有内容将非常耗时。

如果您决定使用 Report Builder Scenario,这可能是最适合您的。这是你必须做的:

第 1 步 - 在 ColdFusion Builder 中为您在报告中拥有的每个不同表格创建 cfr(ColdFsuion Report Builder 模板文件)。这很简单。这是一些文档

步骤 2 使用cfreport为每个“表”生成临时 pdf ,然后使用ddx合并此文件并添加/设计报告的页眉和页脚

于 2014-03-10T19:48:51.617 回答