Esko Logo Back to Esko Support
Choose your language for a machine translation:



Determining if a multi-page PDF has an odd or even number of pages may be needed during a workflow. An example of using this information might be for either a step and repeat or imposition workflow to create the correct number of stations or to create a correct pagination. A router using a Smart Name that determines this could then route the file to a proper branch of a workflow.


As of Automation Engine 14, a new Smart Name called "Number of Pages" that resolves the total number of pages was added to the Automation Engine base. This Smart Name along with a custom created Smart Name of script type can determine if the total is odd or even.

Create a new Smart Name of the type Script

  1. Copy the provided javascript code and replace the placeholder script in the Smart Name.
  2. Name and save the Smart Name.
  3. Use the new Smart Name in a router to route the file correctly.

The Script Smart Name uses the Modulo (or mod) operator. This mod operator is the remainder of division of given numbers. The mod operator is represented by the % symbol. An example of this used in the provided script would be 10 pages divided by 2. This gives us an answer of 5 with a remainder (or mod of) 0. If the answer has a mod of zero, it indicates the initial number (10) is an even number. Another example would be, if there were 11 pages and 11 divided by 2 gives a 5 with a remainder of 1. The result of this mod is 1 and so the number of pages is odd.

Please verify that the Smart Name [Number of Pages] is in the javascript on line 3 replacing <<NrOfPages/>>.

Odd or Even Page count
function f ()
	var numOfPages = <<NrOfPages/>>;
	if(numOfPages%2 == 0)
		{var page = "even";}
		{var page = "odd";}
	return page;
f ();

Other use of Mod operator

This method could also be used to determine any number of pages such as if the multi-page document is divisible by 4 (number in an imposition leaf) by using [Number of pages]%4. This will return a 0 if it is divisible by 4 else a value of 3, 2, or 1.
Article information
Applies to

Automation Engine 14

Last revised 
CW Number