Counting records and inserting pages if needed

I’m looking for suggestions on how to count records, and if needed, insert blanks to fill out the current 3-up sheet. I’m working on imposing postcards 3 up on a sheet. When I hit a tray break in the data (### in column 15), I need to print a data matrix “ejection” barcode one time on the sheet then start a new sheet for the next tray. My thought was that I would count pages, and when I hit the ### signs, check the remainder from a division by 3, then repeat records as needed to fill out the sheet.

I’ve been working on the datamapper with preprocesser properties, but I’m finding they’re the wrong method. Globals can’t be edited and locals get reset every record. What’s the better way to attack this?

Hello @jmdornbos ,

An option is to do a (second) datamapping on the file with the tray breaks, split the file into records when hitting a tray break in the data, and to apply the data as background and add extra pages on content creation (the template side, that is).

Thanks for your response, Marten. I’m not sure how to apply your suggestion to solve the issue. So far, I’m able to generate the extra pages as needed in the template, using record.index %3, but figuring out how many pieces I have in the tray still escapes me. I’ve been searching for a variable where I can store the count of records since the last tray, or a counter I can reset after a tray break is seen, but I’m not having any luck. The value that I really need is (recordsInThisTray % 3). Understandably, the datamapper is very focused on “this current record”. Is there a method for storing a value when ### is seen that I can access as later records are processed? Very similar to the issue I see over in this thread too. Carry value of field to next record.

Thanks,
Jim

Keeping my previous reply in mind: This is possible by applying the datamapper input as background to a print section* and counting the number of pages and adding the extra pages by a Post Pagination Script.

*See Using a PDF file or other image as background for more information.

Thanks for that pointer, Marten. I’ll see what damage I can do with that information.

1 Like