Afternoon, with the item list on a transaction, is...
# advancedpdf
n
Afternoon, with the item list on a transaction, is anyone able to suggest an approach to split the list in to tables of not more than 10 rows per table? So imagine that you have 23 items, I need to split this in to 3 tables- 10 rows, 10 rows, 3 rows. In addition to this I need the last table to actually put in 7 blank rows to ensure that all the tables are 10 rows total. So In reality that would be 3 tables of 10 rows I have thought of a few ways of approaching this but wonder if I'm over complicating things. I've considered asking the client what the max expected items might be and where a header row is needed checking the index, using modulus to ascertain the number of tables and number of rows etc. I appreciate this is quite a broad question but if anyone has done something similar I'd appreciate some direction. Thanks!
n
You can use a user event before load event to add custom fields, split the item data in set of 10 then put the values in custom fields. Then in your PDF pull the item lines from these custom fields instead of sublist.
n
@NickSuite Thanks for replying, only just seen it. Didn't need to go to those lengths thankfully, did it all in the PDF with a bit of fancy freemarker 😉 (*note not me, someone more capable with freemarker 😄 )
n
Oh, great! I just feel it's easier to use and manipulate data in JS than freemarker. That's why I suggested the solution. But I would love to know how this was achieved in freemarker.
n
I don't have access to the account where the work was done but as I recall the list was split out up front into a multi-dimension array. Then an inner / outer loop and tracking lastindex to ascertain if the final table needed bulking out with blank lines. If I get access to the PDF I'll ask if I'm OK to DM you the snippet.
👍 1