Just in case somebody needs it:
Requirement was a datamatrix code for an inserter with following specifications:
7 digits
- digit 1: collect / insert (0=collect sheets, 1=insert, end of collection)
- digit 2-3: sequence over the whole job starting from 00, ending at 99, starting over at 00, thus ensuring that no document is missing.
- digit 4: add product from feeder 2
- digit 5: add product from feeder 3
- digit 6: add product from feeder 4
- digit 7: offset envelope after insertion (for separating ZIP codes or countries)
- digit 8: divert
Code for Output Creation Setting (Additional Barcode):
${(sheet.nr == document.count.sheets) ? '1': '0';}${(sheet.duplex) ? ("00" + (page.sequence.job/2-.5)).slice(-2) : ("00" + (page.sequence.job - 1)).slice(-2);}${(document.metadata.Feeder1 == '1' ) ? '1':'0';}${(document.metadata.Feeder2 == '1' ) ? '1':'0';}${(document.metadata.Feeder3 == '1' ) ? '1':'0';}${(document.metadata.Separate == '1' ) ? '1':'0';}${(document.metadata.Divert == '1' ) ? '1':'0';}
Short explanation of the first two statements:
${(sheet.nr == document.count.sheets) ? ‘1’: ‘0’;} last sheet in dataset is the end of collection
${(sheet.duplex) ? (“00” + (page.sequence.job/2-.5)).slice(-2) : (“00” + page.sequence.job-1).slice(-2);}
if duplex sequence will be half the the number (minus 0.5) with leading "0"es. in simplex just count the pages.
Condition of barcode:
(page.front)
so barcode just prints on the front.
not a really nice solution, but it works. Maybe someone has a hint to beautify that code a bit.
Ralf.