Preprocessors

You can change the source document before it is imposed. This includes reordering, adding and deleting pages, rotating them and more. Everything is done in Preprocessors panel which is the very first on the right:

Preprocessors panel in Imposition Wizard

It is empty by default, but you can add preprocessors using the Plus button at the top right corner of the panel:

Adding a preprocessor in Imposition Wizard

Once the preprocessor is added, it is displayed in the list at the top of the panel. You can add multiple preprocessors using the Plus button and delete them using the Minus button. Right–click the preprocessors in the list to see other options like reordering. Finally, you can temporary disable preprocessors using the checkboxes near their names.

The properties of the selected preprocessor are displayed at the bottom of the panel.

How Preprocessors Work

Each preprocessor performs some operations on the document. It might clone the pages, or rotate them, or shuffle them somehow etc.

The next preprocessor in the list then process the modified document, not the original one.

So preprocessors form a chain or pipe where each one gets the output of its predecessor, does its job and send it further.

The output of the last preprocessor goes for imposition.

Preprocessor Errors

Some configurations might not work for preprocessors and they will report errors. If something goes wrong with a preprocessor it displays the error mark in the list and the detailed error information at the bottom of the source panel when selected.

Preprocessor errors are also displayed in Preflight.

Built–In Preprocessors

Imposition Wizard comes with a number of built–in preprocessors and you can make your own using scripting (there is a dedicate chapter for that below). Here we discuss the simple ones:

Information

This is a very simple preprocessor that does nothing to the document. Instead it displays the number of pages and box sizes for the document at its current preprocessing stage.

The preprocessor is useful to see the document properties. You can add it as the first element of the chain to see what’s in the source document. You can also add it as the last element to see the preprocessing result.

Clone Pages

This preprocessor lets you duplicate pages. It has two parameters Rules and Loop rules for all pages.

The Rules parameter lets you enter a few numbers separated with spaces. Something like “2 1 3”. Imposition Wizard uses the rules line to duplicate the source document pages. For this specific rules line “2 1 3” it will take the first page of the document and make two copies of it, then it will use the second page once and put three copies of the third page.

When it reaches the end of the rules line it checks the other parameter Loop rules for all pages. If it is set, Imposition Wizard will start from the beginning of the rules line, if not — it will simply stop there.

N + 1 Pages

This preprocessor takes a page and makes it a front or back of all the other ones. This is useful if the source document is all fronts, while the first page is the backside shared by all the other pages.

It has two parameters Use page and For other pages that let you configure which page to use as others’ front or back.

You can use negative page number if you want to count from the end of the document.

Using zero or out of range page numbers triggers an error.

Split Pages

This preprocessor lets you take some pages of the source document and drop everything else. For instance, it is useful for taking the cover or inner pages of the brochure.

It has two parameters List of pages to keep and Invert. The list of pages is a line where you put page numbers separated with spaces. All the page number you enter there stays, all that you don’t — get dropped of the document. You can use the same number a few times, this will effectively clone those pages. You can use negative numbers to count pages from the end of the document.

You can define page ranges using “from..to” syntax. Say “1..4” means “pages from 1 to 4”, "-3..-1" means “last 3 pages” and “1..-1” means “all the pages”.

Ranges can go other way, for example “3..1” means “pages 3, 2, 1”. This comes to an interesting trick that lets you reverse the document: "-1..1" which effectively means “all the pages from the last one down to the first one”.

Use the Invert option to drop the listed pages and leave the rest. Note that in this case order of the pages in the rules line doesn’t matter.

Override Box

This preprocessor doesn’t change page order. Instead, it lets you change the page boxes. It takes one of the page boxes (media, crop, bleed, trim or art) as a reference and another (trim or bleed) as a target. Then you can specify the offsets from the reference box, decide if they go inward or outward and get the target box adjusted.

This is useful to re–define the trim box or setup bleeds, yet there is a special preprocessor for bleeds (see below).

Setup Bleeds

This is a very simple preprocessor that takes the trim box of the page, adds the offset you specify and put the result to the bleed box.

You can do the same with the Override Box preprocessor, but this one is simpler.

Scale Pages

This preprocessor lets you scale the pages based on their trim boxes.

The Mode option lets you switch between relative and absolute scaling. The former allows you to enter the scale ration in percent, while the latter requires entering the target page dimensions.

The input and output page sizes are displayed at the bottom of the panel.

Center and Crop

This preprocessor doesn’t scale the page, instead it scales the space it takes on the sheet. Say you have a number of pages of a slightly different size, varying from page to page. This preprocessor makes the all of the same size, centering them in the middle of the specified area.

The Mode parameter works exactly as in the scaling preprocessor: you select between relative and absolute scaling and provide either scaling ratio or target size.

Rotate Pages

This preprocessor can rotate all the pages or just landscape or portrait ones to a given angle.

It helps to prepare a document combined of a different ones where pages might be rotated wrong. You can select all the portrait pages and rotate them 90° to make all the pages landscape.

Script Preprocessor

You can add scripting preprocessor exactly as you add the other ones: using the Plus button at the top right corner of the panel.

Once the script preprocessor added, you will see the empty text box and the error message that the script created no pages. Not good so far, but we’ll sort it out soon.

Imposition Wizard uses JavaScript for scripting preprocessors and you really need to learn the basics of this language in order to use this feature. Below we assume you can code in JavaScript.

The simplest preprocessing script is listed below:

for (const page of iw.pages)
    iw.add(page);

This script loops through all the pages and adds each page just once. Now let’s modify it a bit:

for (const page of iw.pages) {
    iw.add(page);
    iw.add(page);
}

You’ll notice that the pages get duplicated in the document. The reason is that each page is now added twice.

Now here’s the scripting API:

Let’s take a break here and see what we have. All the input pages of the preprocessor come as an array that you can iterate and take individual pages as objects. You can then push these objects to the output of the preprocessor using a special method. We did exactly that above.

Let’s continue with the API. Let’s get the first page of the document:

const p = iw.pages[0];

Here are the properties of the page object:

Here are the methods of the page object:

The methods above require some comments. First of all, the page object you get from iw.pages is a normal JavaScript object, so if you change it, all the other copies will be be changed, too. For example, imagine you did this:

const p1 = iw.pages[0];
const p2 = p1;
p1.angle = 90;

What will you get in p2.angle? You’ll get 90, as p2 is actually the same as p1. Both variables reference the same object, so changing one changes the other.

That’s why you need the clone() method. Here’s the proper code:

const p1 = iw.pages[0];
const p2 = p1.clone();
p1.angle = 90;

Now p2.angle doesn’t get changed when you change p1.

Note that calling clone() doesn’t really clone pages in either source or target lists of the preprocessor. It just makes a copy of the page that does nothing unless it is added to the target set with iw.add().

Use the clone() method if you want to add the same page more than once and need to change its parameters in process. If you simply want to modify the page and add it once, you don’t need to clone it, just modify it in–place.

The p.scalePage(width, height) method is pretty straightforward: it takes the trim box of the page and resize it to the given dimensions (in points). It then scales all the other boxes proportionally.

The p.box(name) and p.setBox(name, box) methods are slightly more complex. The box(name) supports these box names: “media”, “crop”, “bleed”, “trim”, “art” (names are case–sensitive). The method returns an array of 4 numbers, containing left, bottom, right and top positions of the given box:

const trim = p.box('trim');
// trim = [10, 10, 100, 100] - just an example

Note: pages in PDF file can be rotated, see p.angle above. The boxes these methods work with doesn’t take that rotation into account, so the order of numbers in the box arrays might be different, depending on the page rotation angle.

You can then modify the box the way you need and put it back using p.setBxox(name, box) method. Note that only “trim” and “bleed” box can be modified this way.

As the most common box operation is adjusting them using a reference one, we have a special helper method:

// make bleeds
const trim = p.box('trim');
const bleeds = iw.expandBox(trim, 10, 10, 10, 10);
p.setBox('bleed', bleeds);

The iw.expandBox(box, left, bottom, right, top) method takes a box as an array of 4 numbers and 4 offsets in points that it adds the box and returns the result.

Here are some script examples:

// N+1 Pages Preprocessor
for (let i = 1; i < iw.pages.length; i++) {
    iw.add(iw.pages[0]);
    iw.add(iw.pages[i]);
}

// rotate all landscape pages 90º
for (const page of iw.pages) {
    if (page.landscape && page.angle % 180 == 0)
        page.angle += 90;
    iw.add(page);
}

// drop odd pages out
for (let i = 0; i < iw.pages.length; i++) {
    if (i % 2 != 0)
        iw.add(iw.pages[i]);
}

// remove bleeds
for (const page of iw.pages) {
    const box = page.box('trim');
    page.setBox('bleed', box);
}

Contact us if you need a script that is not covered here and you cannot make it yourself.

More Imposition Wizard Tutorials

Installation

Basics

Layouts

Imposition Parameters

Registration Marks

Automation

Command Line

Advanced