Page 1 of 1

[SOLVED] Check for odd number of pages

Posted: Thu Sep 17, 2020 11:58 am
by abonsey
I know I can use Pitstop Server preflights to check for an odd number of pages in a document but I'm looking to keep things tidy and do it with a branch of a flow using Stats.NumberOfPages (see attached).
Do anybody know/care to share how I could do that via the scripting expression?

TIA

Re: Check for odd number of pages

Posted: Thu Sep 17, 2020 1:00 pm
by mkayyyy
Off the top of my head I can't figure out doing it through Define conditions with variables, but doing it fully in a Script expression on a connection would be done like this:

Code: Select all

var numberOfPages = (new FileStatistics(job.getPath())).getNumber("NumberOfPages");

(numberOfPages % 2 == 0);

Re: Check for odd number of pages

Posted: Thu Sep 17, 2020 2:59 pm
by abonsey
FYI
Got there in the end

[Switch.Calculation:Expression="([Stats.NumberOfPages]%2)"]

Re: Check for odd number of pages

Posted: Thu Sep 17, 2020 6:29 pm
by mkayyyy
abonsey wrote: Thu Sep 17, 2020 2:59 pm FYI
Got there in the end

[Switch.Calculation:Expression="([Stats.NumberOfPages]%2)"]
Ah! Can't believe I didn't think of that