NetSuite Advanced PDF 总页码为 0

Posted

技术标签:

【中文标题】NetSuite Advanced PDF 总页码为 0【英文标题】:NetSuite Advanced PDF Total Page Number is 0 【发布时间】:2018-12-05 07:44:57 【问题描述】:

我正在创建一个高级 PDF,由于某种原因,内置的总页码在每个呈现的页面上显示为 0。我在页脚宏中使用。但是,当前页面工作正常,并且每个页面都正确递增,但页脚仅显示 0 中的 1、0 中的 2 等。 有没有其他人有这个问题? (我的模板/代码基于显示销售订单项目的已保存搜索)

<?xml version="1.0"?><!DOCTYPE pdf PUBLIC "-//big.faceless.org//report" "report-1.1.dtd">
<pdf>

<#list results as mainline>	<#-- loops through the each item that is the first in an order -->
  <#if !currentOrder?has_content || (mainline.tranid != currentOrder)>
    <#assign currentOrder = mainline.tranid/>

<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>
<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;
          	border-collapse: collapse;
		
		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: 5px;
			padding-top: 5px;
		
      	table.itemtable tr 
          	border-bottom: 1px solid black;
        
		table.itemtable tr:last-child 

		
		table.body td 
			padding-top: 2px;
		
		td.addressheader 
			font-size: 8pt;
			padding-top: 8px;
			padding-bottom: 2px;
		
		td.address 
			padding-top: 0px;
		
		span.title 
			font-size: 18pt;
          	font-weight: bold;
		
		span.number 
			font-size: 16pt;
		
		span.itemname 
			font-weight: bold;
			line-height: 150%;
		
      	span.total 
          display: block;
          font-weight: bold;
		
		hr 
			width: 100%;
			color: #d3d3d3;
			background-color: #d3d3d3;
			height: 1px;
		
</style>
      <macrolist>
        <macro id="nlfooter">
          <table class="footer" style="width: 100%;"><tr>
            <td align="right"> <pagenumber/> of <totalpages/></td>
            </tr>
          </table>
        </macro>
        <macro id="nlheader">
          <table class="header" style="width: 100%;">
            <tr>
              <td rowspan="3"><#if companyInformation.logoUrl?length != 0><img dpi="300" src="" style="float: left; margin: 7px" /> </#if>
              </td>
              <td align="right"><span class="title">PICK TICKET</span></td>
            </tr>
            <tr>
              <td align="right">$mainline.trandate</td>
            </tr>
            <tr>
              <td align="right" style="vertical-align: middle;"><barcode codetype="code128" showtext="true" value="$mainline.tranid"/></td>
            </tr>
            <tr>
              <td rowspan="3" style="vertical-align: middle;  width: 28%;"><span class="nameandaddress">$companyInformation.addressText</span></td>
            </tr>
          </table>
        </macro>
      </macrolist>
</head>

<body header="nlheader" header- footer="nlfooter" footer- padding="0.5in 0.5in 0.5in 0.5in" size="Letter" pagenumber="1">
   <table style="width: 100%;">
     <tr>
        <td class="addressheader"><b>$mainline.billaddress@label</b></td>
        <td class="addressheader"><b>$mainline.shipaddress@label</b></td>
        <td class="addressheader"><b>$mainline.otherrefnum@label</b></td>
     </tr>
      <tr>
        <td class="address">$mainline.billaddress</td>
        <td class="address">$mainline.shipaddress</td>
        <td class="address">$mainline.otherrefnum</td>
	  </tr>
  </table>
  <table class="body" style="width: 100%; margin-top: 10px; border: 1px">
	<tr>
        <th>$mainline.trandate@label</th>
        <th>$mainline.shipmethod@label</th>
        <th>$mainline.terms@label</th>
      	<th>$mainline.salesrep@label</th>
        <th>$mainline.custbody_entered_by@label</th>
      </tr>
      <tr style="border-top: 1px">
        <td>$mainline.trandate</td>
        <td>$mainline.shipmethod</td>
        <td>$mainline.terms</td>
        <td>$mainline.salesrep</td>
        <td>$mainline.custbody_entered_by</td>
      </tr>
  </table>

  <table class="itemtable" style="width: 100%; margin-top: 10px;">
    <tr style="border: 1px; border-right: 1px; border-left: 1px;">
      <th colspan="4" style="border-left: 1px;">$mainline.item@label<br /><span style="font-weight: normal;">Item Description</span></th>
      <th>$mainline.locationnohierarchy@label</th>
      <th>Ordered</th>
      <th>Committed</th>
      <th >$mainline.unit@label</th>
      <th >$mainline.weight@label</th>
      <th style="border-right: 1px;"   align="right">$mainline.amount@label</th>
    </tr>

<#assign totalWeight =0/>
<#assign totalAmount =0/>

    <#list results as resultitem>
<#if resultitem.item?has_content && (resultitem.tranid == mainline.tranid)>  <#-- loops through the corresponding items for the current order -->

<#-- Sums the total items of a single order -->
<#assign totalItems = 0/>
<#list results as loopitem>
  <#assign currentOrdNum = loopitem.tranid/>
  <#if currentOrdNum == resultitem.tranid>
    <#assign totalItems++/>
    </#if>
</#list>

<#-- Finds which item line number the current loop is on -->
<#if !ordNum?has_content>
  <#assign ordNum = resultitem.tranid/>
  <#assign currentItem = 1/>
<#elseif ordNum == resultitem.tranid>
  <#assign currentItem++/>
<#else>
  <#assign ordNum = resultitem.tranid/>
  <#assign currentItem = 1/>
</#if>

<#assign totalWeight += resultitem.weight/>
<#assign totalAmount += resultitem.amount/>
<#if currentItem != totalItems>
      <tr>
        <td colspan="4"><span class="itemname">$resultitem.item</span><br />$resultitem.displayname</td>
        <td>$resultitem.locationnohierarchy</td>
        <td>$resultitem.quantity</td>
        <td>$resultitem.quantitycommitted</td>
        <td>$resultitem.unit</td>
        <td>$resultitem.weight&nbsp;$resultitem.weightunit</td>
        <td  align="right">$resultitem.amount</td>
      </tr>
<#else>
      <tr>
        <td colspan="4"><span class="itemname">$resultitem.item</span><br />$resultitem.displayname</td>
        <td>$resultitem.locationnohierarchy</td>
        <td>$resultitem.quantity</td>
        <td>$resultitem.quantitycommitted</td>
        <td>$resultitem.unit</td>
        <td>$resultitem.weight&nbsp;$resultitem.weightunit</td>
        <td align="right">$resultitem.amount</td>
      </tr>
  	  <tr style="border-bottom: none;">
        <td colspan="7"></td>
        <td colspan="2" align="right">Total Weight:</td>
        <td align="right">$totalWeight&nbsp;$resultitem.weightunit</td>
  	 </tr>
  	 <tr>
        <td colspan="7"></td>
        <td colspan="2" align="right"><span style="font-weight:bold;">Grand Total:</span></td>
        <td align="right">$totalAmount?string.currency</td>
  	</tr>
</#if>

</#if>
</#list>

</table>
</body>
<#else>
  <head>
  </head>
  <body>

  </body>
</#if>
</#list>
</pdf>

【问题讨论】:

请包含您的模板代码。 添加代码以发布。 【参考方案1】:

很遗憾,BFO 引擎无法预先计算页数。

如果您知道报告的每个部分有多大,您就可以准确计算页数并将其存储在变量中

您已经在做一些类似于计算 currentOrdNum 所需的事情

【讨论】:

以上是关于NetSuite Advanced PDF 总页码为 0的主要内容,如果未能解决你的问题,请参考以下文章

NetSuite Advanced PDF - 使用记录中的多选字段过滤项目表列表

Netsuite 高级 PDF/HTML 模板:将页脚设置为仅显示在最后一页

MPDF:重置总页码

Netsuite PDF模板:获取页数作为属性

使用飞碟,如何在页脚的每一页上生成一个带有页码和总页数的 pdf?

博客园文章转PDF之非多线程方式