Output Creation - Page Counter

Hi,

Hopefully someone can provide some guidance with how I can get an incremental counter on a PDF document containing records of various lengths.

I have an Output Preset with Additional Content generating a barcode which needs the above counter for our envelope stuffing machine.

I have tried a few variations of the Print Variables available but cannot get the required output.

A single sheet record starts with 3, a multi page one has 2 as its start digit, 0 for middle and 1 for end.

The required output should be as below - the end digit should be incremental counter:

Page 1 – Record 1 – Single page – Barcode 3001
Page 2 – Record 2 – Single page – Barcode 3002
Page 3 – Record 3 – Start Multi page - Barcode 2003
Page 4 – Record 3 – Middle Multi Page - Barcode 0004
Page 5 – Record 3 – End Multi Page – Barcode 1005
Page 6 – Record 4 – Single Page – Barcode 3006

The only output I have been able to produce is:

Page 1 – Record 1 – Single page – Barcode 3001
Page 2 – Record 2 – Single page – Barcode 3003
Page 3 – Record 3 – Start Multi page - Barcode 2005
Page 4 – Record 3 – Middle Multi Page - Barcode 0007
Page 5 – Record 3 – End Multi Page – Barcode 1009
Page 6 – Record 4 – Single Page – Barcode 300B (a Base32 number to keep to 4 character limit)

Or the following

Page 1 – Record 1 – Single page – Barcode 3001
Page 2 – Record 2 – Single page – Barcode 3001
Page 3 – Record 3 – Start Multi page - Barcode 2004
Page 4 – Record 3 – Middle Multi Page - Barcode 0004
Page 5 – Record 3 – End Multi Page – Barcode 1004
Page 6 – Record 4 – Single Page – Barcode 3005

Is there a Print Output variable I have missed?

Many thanks in advance

The last attempt looks good, except for the page counter at the end.
You can use page.sequence.job to get the page number within the job.

To get leading zeros you can use ${format.formatNumber(page.sequence.job,'000')}.

https://help.objectiflune.com/en/planetpress-connect-user-guide/2021.2/#designer/Output/Print/Variables_available_in_the_Output.htm?Highlight=output%20variable

Hope that helps. Otherwise it would be helpful to see the code you already tried.