Scenario
To evaluate the current Sales Invoice rendering logic, specifically whether it’s controlled by Suitelet scripting or Advanced PDF/HTML templates and explore the feasibility of implementing a solution where long item descriptions automatically continue to the next page in the invoice PDF. The goal is to overcome the 500-character display limit and layout constraints without compromising the formatting or stored data integrity.
Solution
We have reviewed the current Sales Invoice rendering logic in the advanced PDF template, which imposes a 500-character limit for long item descriptions. To address this, the current logic splits descriptions into line breaks and manages the item table accordingly. For excessively lengthy single sentences, we can divide them by characters and configure the item table.
Currently, a maximum of 10 lines can fit on a single page, and we can adjust the size based on the maximum header dimensions.
Template Update
<#assign totalQuantity = 0 />
<#assign serialNumber = 0 /> <!-- Initialize a serial number variable --> <!-- start items --> <#list record.item as item>
<#if item.description?has_content>
<#assign rawDesc = item.description?replace("(?i)<brs*/?>", "||", "r") />
<#assign charList = rawDesc?split("||") />
<#assign chunks = charList?chunk(10) /> <!-- chunks of 10 lines -->
</#if>
<tr style="border-top:1px solid black;">
<td align="center" style="border-right:1px solid black;width:5%;padding-top:10px;padding-bottom:10px;"><#assign serialNumber = serialNumber + 1 /> ${serialNumber}</td>
<td align="left" style="border-right:1px solid black;padding-top:10px;padding-bottom:10px" colspan="2">
<#if chunks?size gt 0>
<br/>
<#list chunks[0] as ch>${ch}<br/></#list>
</#if>
<span>${item.item}</span>
</td>
<#if item.custcol_in_hsn_code?has_content>
<#assign hsn_code = item.custcol_in_hsn_code?substring(0, item.custcol_in_hsn_code?index_of(" "))>
<#else>
<#assign hsn_code = " ">
</#if>
<td align="left" style="border-right:1px solid black;padding-right:4px;padding-top:10px;padding-bottom:10px">${hsn_code}
</td>
<td align="right" style="border-right:1px solid black;padding-right:4px;padding-top:10px;padding-bottom:10px">${item.quantity}
<#assign totalQuantity = totalQuantity + item.quantity />
</td>
<td style="border-right:1px solid black;padding-right:4px;padding-top:10px;padding-bottom:10px" align="right">${item.rate}</td>
<td align="left" style="border-right:1px solid black;padding-right:4px;padding-top:10px;padding-bottom:10px">${item.units}</td>
<td align="right" style="padding-right:4px;padding-bottom:10px;padding-top:10px">${item.amount}</td>
</tr>
<#if chunks?size gt 1>
<#list chunks[1..] as chunk>
<tr>
<td style="border-right:1px solid black;"></td>
<td align="left" style="border-right:1px solid black;padding-top:10px;padding-bottom:10px" colspan="2">
<#list chunk as ch>${ch}<br/></#list>
</td>
<td style="border-right:1px solid black;"></td>
<td style="border-right:1px solid black;"></td>
<td style="border-right:1px solid black;"></td>
<td style="border-right:1px solid black;"></td>
<td style="border-right:1px solid black;"></td>
<td ></td>
</tr>
</#list>
</#if>