You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Advanced PDF技术问题:无法添加每页显示的页眉小表格

解决NetSuite Advanced PDF页眉添加配送信息表格的问题

你的问题核心是要让表格在每页页眉显示,必须把表格代码放到定义页眉的nlheader宏里,而不是<body>或直接放<head>里。以下是具体修改方案:

问题原因

  • 放在<body>里的表格只会在第一页显示,分页后后续页面不会重复渲染
  • <head>标签内只能放样式、字体、宏定义等,直接放表格代码会触发语法错误

修改后的完整代码

重点修改了nlheader宏,加入了配送信息表格,并调整了header-height避免内容截断:

<head>
    <link name="NotoSans" type="font" subtype="truetype" src="${nsfont.NotoSans_Regular}" src-bold="${nsfont.NotoSans_Bold}" src-italic="${nsfont.NotoSans_Italic}" src-bolditalic="${nsfont.NotoSans_BoldItalic}" bytes="2" />
    <#if .locale == "zh_CN">
        <link name="NotoSansCJKsc" type="font" subtype="opentype" src="${nsfont.NotoSansCJKsc_Regular}" src-bold="${nsfont.NotoSansCJKsc_Bold}" bytes="2" />
    <#elseif .locale == "zh_TW">
        <link name="NotoSansCJKtc" type="font" subtype="opentype" src="${nsfont.NotoSansCJKtc_Regular}" src-bold="${nsfont.NotoSansCJKtc_Bold}" bytes="2" />
    <#elseif .locale == "ja_JP">
        <link name="NotoSansCJKjp" type="font" subtype="opentype" src="${nsfont.NotoSansCJKjp_Regular}" src-bold="${nsfont.NotoSansCJKjp_Bold}" bytes="2" />
    <#elseif .locale == "ko_KR">
        <link name="NotoSansCJKkr" type="font" subtype="opentype" src="${nsfont.NotoSansCJKkr_Regular}" src-bold="${nsfont.NotoSansCJKkr_Bold}" bytes="2" />
    <#elseif .locale == "th_TH">
        <link name="NotoSansThai" type="font" subtype="opentype" src="${nsfont.NotoSansThai_Regular}" src-bold="${nsfont.NotoSansThai_Bold}" bytes="2" />
    </#if>
    <macrolist>
        <macro id="nlheader">
            <!-- 原有页眉内容 -->
            <table class="header" style="width: 100%;"><tr>
                <td rowspan="3"><#if companyInformation.logoUrl?length != 0><img src="http://XXXXXXX.shop.netsuite.com/core/media/media.nl?id=11&amp;c=7203566&amp;h=NSaadJ6sqFB7h5yvBSShikbm1V16LLZpMjxRBnK83Udek2SH" style="float: left; margin: 7px; width: 250px; height: 141px;" /> </#if></td>
                <td align="right"><span class="title">${record@title}</span></td>
            </tr>
            <tr>
                <td align="right"><span class="number">Sales Order#${record.tranid}</span></td>
            </tr>
            <tr>
                <td align="right">${record.trandate}</td>
            </tr></table>
            
            <!-- 新增的配送信息表格 -->
            <table border="0" cellpadding="1" cellspacing="1" style="width:100%; margin-top: 8px;">
                <thead>
                    <tr>
                        <th scope="col">
                            <p align="center">Route Date</p>
                        </th>
                        <th scope="col">
                            <p align="center">Truck Number</p>
                        </th>
                        <th scope="col">
                            <p align="center">Stop Number</p>
                        </th>
                    </tr>
                </thead>
                <tr>
                    <td>
                        <p align="center">${record.custbody54}</p>
                    </td>
                    <td>
                        <p align="center">${record.custbody53}</p>
                    </td>
                    <td>
                        <p align="center">${record.custbody50}</p>
                    </td>
                </tr>
            </table>
        </macro>
        <macro id="nlfooter">
            <table class="footer" style="width: 100%;"><tr>
                <td><barcode codetype="code128" showtext="true" value="${record.tranid}"/></td>
                <td align="right"><pagenumber/> of <totalpages/></td>
            </tr></table>
        </macro>
    </macrolist>
    <style type="text/css">* {
        <#if .locale == "zh_CN">
            font-family: NotoSans, NotoSansCJKsc, sans-serif;
        <#elseif .locale == "zh_TW">
            font-family: NotoSans, NotoSansCJKtc, sans-serif;
        <#elseif .locale == "ja_JP">
            font-family: NotoSans, NotoSansCJKjp, sans-serif;
        <#elseif .locale == "ko_KR">
            font-family: NotoSans, NotoSansCJKkr, sans-serif;
        <#elseif .locale == "th_TH">
            font-family: NotoSans, NotoSansThai, sans-serif;
        <#else>
            font-family: NotoSans, sans-serif;
        </#if>
        }
        table {
            font-size: 9pt;
            table-layout: fixed;
        }
        th {
            font-weight: bold;
            font-size: 8pt;
            vertical-align: middle;
            padding: 5px 6px 3px;
            background-color: #e3e3e3;
            color: #333333;
        }
        td {
            padding: 4px 6px;
        }
        td p { align:left }
        b {
            font-weight: bold;
            color: #333333;
        }
        table.header td {
            padding: 0;
            font-size: 10pt;
        }
        table.footer td {
            padding: 0;
            font-size: 8pt;
        }
        table.itemtable th {
            padding-bottom: 10px;
            padding-top: 10px;
        }
        table.body td {
            padding-top: 2px;
        }
        td.addressheader {
            font-size: 8pt;
            padding-top: 6px;
            padding-bottom: 2px;
        }
        td.address {
            padding-top: 0;
        }
        span.title {
            font-size: 28pt;
        }
        span.number {
            font-size: 16pt;
        }
        span.itemname {
            font-weight: bold;
            line-height: 150%;
        }
        hr {
            width: 100%;
            color: #d3d3d3;
            background-color: #d3d3d3;
            height: 1px;
        }
</style>
</head>
<body header="nlheader" header-height="15%" footer="nlfooter" footer-height="20pt" padding="0.5in 0.5in 0.5in 0.5in" size="Letter">
    <table style="width: 100%; margin-top: 10px;"><tr>
        <td class="addressheader"><b>${record.shipaddress@label}</b></td>
    </tr>
    <tr>
        <td class="address">${record.shipaddress}</td>
    </tr></table>
</body>

关键修改点

  1. 将配送表格移入nlheader宏:宏定义的内容会在每页页眉区域自动渲染
  2. 调整header-height:从原来的10%改为15%,确保新增表格有足够显示空间,避免被截断
  3. 移除内的重复表格:避免第一页重复显示

验证步骤

  1. 替换原代码为修改后的版本
  2. 在NetSuite中预览PDF,确认每页页眉都显示配送信息表格
  3. 如果仍有截断问题,可继续增大header-height的值(比如20%)

内容的提问来源于stack exchange,提问作者CO_NetSuite_Guy

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.11 15:29:50