嵌套自由标记表中的分页符

问题描述 投票:0回答:1

我正在使用 Free Marker 创建 Netsuite 自定义表单。我试图迭代记录对象中的每个项目并为相应的条目创建一行。 我已按计费类别将条目分开,效果很好。但分页逻辑没有按例外情况工作。该页面没有脱离

<pbr></pbr>
标签。

这是本节的代码

<table style="width: 100%; border: 0px;">
<tr>
<td align="center">
    <p><strong style="font-size: 10;">foo bar, LLC</strong></p>
    <p><strong style="font-size: 12;">Time by Job Detail</strong></p>
    <p><strong style="font-size: 12;">${record.job}</strong></p>
    <hr class="thick-hr" />
    <table>
        <tr>
            <td class="underline-container"><span class="underline">Date</span></td>
            <td class="underline-container"><span class="underline">Name</span></td>
            <td class="underline-container"><span class="underline">Billing Status</span></td>
            <td class="underline-container"><span class="underline">Duration</span></td>
        </tr>

        <!-- Grouping by Billing Class -->
        <#assign billingClasses = [] />
        <!-- Get distinct billing classes -->
        <#list record.item as timeEntry>
            <#if !billingClasses?seq_contains(timeEntry.item)>
                <#assign billingClasses += [timeEntry.item] />
            </#if>
        </#list>
        <#assign rowsPerPage = 30 />
        <#assign rowCount = 0 />
        <#assign totalDuration = 0 />

        <!-- Iterate through each billing class -->
        <#list billingClasses as billingClass>
            <tr>
                <td colspan="4" style="font-weight: bold; text-align: left;">${billingClass}</td>
            </tr>

            <!-- Iterate through items that belong to the current billing class -->
            <#list record.item?filter(it -> it.item == billingClass) as timeEntry>
                <#if rowCount != rowsPerPage>
                    <tr>
                        <td>${timeEntry.billeddate}</td>
                        <td>${timeEntry.employeefullname}</td>
                        <td>${timeEntry.item}</td>
                        <td>${timeEntry.quantity}</td>
                    </tr>
                    <#assign totalDuration += timeEntry.quantity />
                    <#assign rowCount = rowCount + 1 />
                <#else>
                    <!-- Page Break when reaching the rowsPerPage limit -->
                    </table><pbr></pbr><table>
                    <tr>
                        <td colspan="4" style="font-weight: bold; text-align: left;">${billingClass}</td>
                    </tr>
                    <tr>
                        <td>${timeEntry.billeddate}</td>
                        <td>${timeEntry.employeefullname}</td>
                        <td>${timeEntry.item}</td>
                        <td>${timeEntry.quantity}</td>
                    </tr>
                    <#assign totalDuration += timeEntry.quantity />
                    <#assign rowCount = 1 /> <!-- Reset rowCount after page break -->
                </#if>
            </#list>
        </#list>

        <tr>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td style="text-align: right; font-weight: bold;">Total:</td>
            <td style="font-weight: bold;">${totalDuration}</td>
        </tr>
    </table>
</td>
</tr>
</table>

感谢任何指导!

我正在尝试在自由标记中达到一定行数后创建分页符。

templates netsuite freemarker pdfhtml
1个回答
0
投票

如果您正在打印 PDF,NetSuite 的 BFO 引擎实际上会为您处理表格中的分页符。如果您希望表格标题在分页时重复,您可以在表格上创建一个

<thead>
元素,请参阅 https://bfo.com/products/report/docs/tags/tags/tbody.html

如果您有嵌套表格并且想要避免分页符,您可以将

page-break-inside="avoid"
添加到嵌套表格元素中。还有
page-break-after1
page-break-before
属性可实现更精细的控制。

https://bfo.com/products/report/docs/tags/atts/page-break-inside.html https://bfo.com/products/report/docs/tags/atts/page-break-after.html

© www.soinside.com 2019 - 2024. All rights reserved.