Printing the Sum of an Item sublist field without needing an additional custom field is possible by using the Assign tag in the Source code editor of Advanced PDF/HTML Templates.
A sample scenario would be to print the sum of the Item Quantity in a Sales Order record. We need to enter the <#assign> syntax after the <table> part of the code. The sample code would be like this:
In the image above, we have added the <#assign totalquantity = 0> after the <table> syntax. The second part would be to add the following code below:
In the image above, we have added the code <#assign totalquantity = (item.quantity + totalquantity)> to compute for the sum of the quantity of the Item lines. After this, we can now enter ${totalquantity} to print the total quantity of the Item lines in the Sales Order. The whole code would look like this:
Let us know if you have further questions or clarifications! ?