Working with Pre Script to Search for Images

When creating a catalog, a price list or a campaign paper, data does contain every infomations available. But for some production that’s not enough. Part of the data could be missing in relation to the graphic production, like the correct link/locations to the images. If your images reside within folders and subfolders, and more subfolders this is the tutorial you will need to read.

In this tutorial we will take a look of how a script can manipulate the data source to include the full path to the images, just by using the ItemNo or ProductCode as a search term.

PJS Prescript

What is a Pre Script File?
A pre script file is a javascript file that is using standard java script to execute different command or functions. It could be a script that prepare your page just before running the production it self. In this tutorial we are using the script to manipulate the data of the production to fix the missing location of image files.

Setting up the project
The project settings we are using in this tutorial is the “Bikes demo” project which is included in a standard installation of both Cacidi Extreme and Cacidi LiveMerge. Start by downloading the script for the tutorial here.

First create a copy of the “Bikes demo” project, by selecting the “Bikes demo” project and the choosing New in the popup menu in the top/left corner of the Project Settings dialog box. Now remove the Image path to the images, so it’s left empty.

Select the script you just have downloaded in the Pre-Script file part of the dialog.

Adjusting parameters to the script file path
The contents of the Pre-Script file should now contain the full path to the script, but you will manually have to add two different information/arguments the script need to run.
The start of the search, e.g. C:\myImages\ or Macintosh HD:myImages:
The field the we will search for, in this case we will use the ItemNo field in the data source
The information is added to the file path to the script, within a bracket like this.

On a Mac it could look like this
mypathtothescriptfile:PrescriptSearchImages.jsx(Macintosh HD:myImages:,ItemNo)
or on Windows

The search part
The search will include the full name of the file, which means that if you have multiple files connected to the search, all images will be find, and added in the ordre that they are found.

The result
When dragging a design to the page from LiveMerge, first time the script will be searching for images, and create 5 new merge fields
Image-1, Image-2, Image-3, Image-4 and Image-5. Those are the merge field you must use to access the images. Try to create a text frame (just to see what’s going on), and insert these merge fields

Save the test design, and drag the item from LiveMerge, or create a small step-and-repeat production with Extreme.

Speed issues
Searching through i large harddrive with thousands of images can be a time consuming task. The pre-script and data are cached when used with LiveMerge, so the first time you drag a snippet to the page the search is performed, and you will notice a great improvement for the next snippets to be dragged.

Leave a Reply