Numbered Tickets by Using Pre-Script

When creating lot of different jobs like tickets you will need to get a unique number of each ticket, and you will need to have the data sorted in a way that will make it easy to cut the tickets afterwards. The pattern the numbers in are really importance.

Most often you don’t have the data, you can of course enter Microsoft Extreme and create the data manually, but it’s a quite large and boring task.

In this tutorial, we will show how a small and easy script can create the data for the production, and how Cacidi Extreme’s pre-script function can manipulate the data on the fly.

Load the Project
Start by choosing the “Tickets” tutorial project. The Project dialog should look like this.

TICKETPJ

The Pre-Script function
The pre-script function are a build in way of intercept a catalog production, it can be used to accomplish a lot task, like setting the document before run, mark the start time or as we will show here, manipulate the date on-the-fly. The pre-script are executed, after the data is loaded (and the grouping, if used, has occurred) and before the production are started, juste there between data load and production. We are receiving the data fra the data source in the script so it’s a great place to manipulate the content. Take a good look at the “Pre-Script File” setting and see how the function points to a javascript file.

Macintosh HD:Cacidi Demo:Tickets:PrescriptTickets.jsx(20,4,1,3)

The path to the file are properly different on your machine, but you should have attention to the info between the brackets the (20,4,1,3), these are parameters send from the project settings UI to the script. The first parameter are how many pages you would like to produce, the second are how many tickets you have on the page, and the third number are which number the tickets should start from, and the fourth are the number of digit the number should have.

TICKET4X1
Running a production
First open the “Tickets.indd”, you can easily open the template by choosing the file in the “Select an InDesign Template” popup menu in the basic panel of the Cacidi Extreme palette. Then change the grid on the page to have 4 columns, 1 row, and 3 mm in page gutters (use the grid settings on the top of the panel). Then choose the “Tickets 4×1.idms” file in the “Select an ItemDesign” , in the popup menu. Press the Create button. 
Now 20 pages with 4 tickets with the right stacking order, for easy cutting should have been produced.

TICKET5X2
Running a 10 tickets on each page production
Change the project settings “Pre-Script File” settings to support 10 per page by changing the second parameter from 4 to 10, and change the third parameter from a starting point from 1 to 101.

Macintosh HD:Cacidi Demo:Tickets:PrescriptTickets.jsx(20,10,101,3)

Now delete all pages in the document, and apply the B-Master to page 1, change the grid of the page to 5 columns, 2 rows and 3mm in gutters. Now select the “Tickets 5×2.idms” in the “Select an ItemDesign” popup menu and Press the “Create” button.

An in-deep work through of the script
This is for you if you are a technical person or a curious person who want to know about the interception that you can do with pre-script.

A short block description
1) Get info from the project settings vars, those described as parameters and the data from the data source
2) Manipulate the data or do stuff that should be executed at this time
3) Put the manipulated data i the return parameters

The full script
var NumOfPages=100;
var ItemsOfPages=10;
var StartOfTickets=1;
var NumOfDigits=3;

// JUST A FUNCTION TO ADD ZEROS
function zeroPad(num, places) {
var zero = places – num.toString().length + 1;
return Array(+(zero > 0 && zero)).join(“0”) + num;
}

//GET THE PARAMETERS AND DATA
args = app.scriptArgs;
//var headerData=args.getValue(“HeaderData”);
var productionData=args.getValue(“ProductionData”);
var scriptArguments = args.get(“scriptArguments”);

//USE DEFAULT VALUES IF NOT STATED
if(scriptArguments.length>0)
{
scriptArgumentsParts=scriptArguments.split(“,”);
NumOfPages=scriptArgumentsParts[0];
ItemsOfPages=scriptArgumentsParts[1];
StartOfTickets=scriptArgumentsParts[2];
}

//TWO LOOPS ADDING NUMBERS
var dataline=””;
for (i=0; i<NumOfPages; i++)
{
for (x=0;x<ItemsOfPages;x++){
dataline+=formatNumbers((StartOfTickets*1)+i+(x*NumOfPages))+”\r”;
}

}
//SENDING THE DATA BACK TO INDESIGN
args.setValue(“ProductionData”,dataline);

Leave a Reply