CFdocumentitem Pagebreak无效

时间:2017-03-15 21:49:08

标签: pdf coldfusion

我正在使用cfdocument将表格内容保存为PDF。我正在使用cfoutput为查询中的每一行生成一个。每x行,我想强制分页,插入表的标题行,并继续循环查询。相反的是,在表和表之间插入了几个分页符,它完全忽略了分页符的位置。标签不应该在表格内工作吗?我的代码如下:

<cfdocument format="pdf" orientation="landscape">
    <h1>Cumulative Daily Report</h1>
        <table id="displayTable" cellspacing="0">
            <tr>
                <th>Specialist</th>
                <th>Asmnts</th>
                <th>Avg Length</th>
                <th>Day 2 Returns</th>
                <th>QPRs</th>
                <th>NCAs</th>
                <th>Asmnts</th>
                <th>Avg Length</th>
                <th>Day 2 Returns</th>
                <th>QPRs</th>
                <th>NCAs</th>
                <th># of Days</th>
                <th>AEU/th>
                <th>Asmnts</th>
                <th>QPRs</th>
                <th>NCAs</th>
                <th># of Days</th>
                <th></th>
            </tr>
            <cfoutput query="qryDisplay">
                    <cfif qryDisplay.currentRow MOD (rowsPerPage + 1) EQ 0>
                        <cfdocumentitem type="pagebreak"></cfdocumentitem>           <tr>
                            <td colspan="18">Column Header Row here</td>
                         </tr>
                    </cfif>
                <tr>
                    <td>#SpecialistName#</td>
                    <td>#numberFormat(nSixNumAssess, ",")#</td>
                    <td>#numberFormat(nSixAvgLength, ",")#</td>
                    <td>#numberFormat(nSixDay2Rets, ",")#</td>
                    <td>#numberFormat(nSixQPRs, ",")#</td>
                    <td>#numberFormat(nSixNCAs, "_._")#</td>
                    <td class="contrastBG">#numberFormat(nRtscNumAssess, ",")#</td>
                    <td class="contrastBG">#numberFormat(nRtscAvgLength, ",")#</td>
                    <td class="contrastBG">#numberFormat(nRtscDay2Rets, ",")#</td>
                    <td class="contrastBG">#numberFormat(nRtscQPRs, ",")#</td>
                    <td class="contrastBG">#numberFormat(nRtscNCAs, "_._")#</td>
                    <td>#numberFormat(nSixNumDaysWorked, ",")#</td>
                    <td class="bold">#numberFormat(nSixAEU,"_.__")#</td>
                    <td class="contrastBG">#numberFormat(nWecareNumAssess, ",")#</td>
                    <td class="contrastBG">#numberFormat(nWecareQPRs, ",")#</td>
                    <td class="contrastBG">#numberFormat(nWecareNCAs,"_._")#</td>
                    <td class="contrastBG">#numberFormat(nWecareNumDaysWorked, ",")#</td>
                    <td class="contrastBG bold rightBorder">#numberFormat(nWecareAEU,"_.__")#</td>
                </tr>
            </cfoutput>
        </table>
</cfdocument>

3 个答案:

答案 0 :(得分:2)

问题是你试图在一张桌子内打破。 cfdocument的html渲染器无法处理。

要修复此问题,您必须使用TR循环,并为每个创建的页面添加打开/关闭表标记(以及标题行)。

请记住在循环开始之前使用开始表标记和标题行,然后关闭表格。

答案 1 :(得分:1)

我发现,如果页面确实放在了td中,那么该页面确实有效。所以我最终创建了一个分页符并在每x行中向文档中插入一个标题行,其中x是用户输入的数字,默认为15.所以:

<cfoutput query="qryDisplay">
                <cfif qryDisplay.currentRow MOD (form.rowsPerPDFPage + 1) EQ 0>
                     <!---do a pagebreak and insert header rows. Pagebreak must be inside the td tag to work--->
                    <tr>
                        <td colspan="18" class="noBorder">
                             <cfdocumentItem type="pagebreak" />
                        </td>
                    </tr>
                    <tr>
                        <td class="bottomBorderOnly"></td>
                        <th class="topBorder leftBorder" colspan="5">Sixteenth Street</th>
                        <th class="topBorder"colspan="5">RTSC/SRT</th>
                        <th class="topBorder"colspan="2">16th/RTSC</th>
                        <th class="topBorder rightBorder" colspan="5">WeCARE</th>
                    </tr>

答案 2 :(得分:0)

cfdocumentitem type =“ pagebreak”在表内不起作用,因此请先关闭表,然后再放回并打开同一表;

import {MatDatepickerModule} from '@angular/material/datepicker';
.
.
.
.

@NgModule({
  declarations: [
    AppComponent,
    .
    .
    .
    .
  ],
  imports: [
    BrowserModule,
    MatDatepickerModule,
    .
    .
    .
    .
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }