With all that is new coming to InDesign and the rest of the Creative Suite (now Creative Cloud) we will be turning our attention to tips and tricks for working with some of the new features. But first, before we close the door on our script for creating a new document, we might think of a scenario that happens all too often when we present a new script to the user.


Case in point. The user reports that she really likes the script, but points out the fact that many of the documents she creates could use a single document preset with one exception, the document may or may not require a bleed and or slug. Since your workflow dictates standard settings for bleed and slug, she thinks having to have a two document presets for each layout (one with, one without the bleed) seems redundant. She suggests adding two more fields to the custom dialog:

  • checkbox for bleed
  • checkbox for slug

The request is granted. Now you need to add the fields to the custom dialog, and pass the checked state of each back to the script. The script will need to add two functions to respond depending on the state of one or both of the checkboxes.

Let’s work through the process.



--create a row to hold the checkboxes inside the tell dlgRef block
set chkRow to make dialog row
--create variables to hold reference to each checkbox as part of its being created 
tell chkRow
   set chkBleed to make checkbox control with properties {static label: "Add bleed:", checked state:false}
   set chkSlug to make checkbox control with properties {static label: "Add slug:", checked state: true}
end tell


//create a row to hold the checkboxes with the dialog column as its parent
var chkRow = dialogColumn.dialogRows.add();
//create variables to hold reference to each checkbox as part of its being created
var chkBleed = chkRow.checkboxControls.add({staticLabel:"Add bleed:", checkedState:false});
var chkSlug = chkRow.checkboxControls.add({staticLabel:"Add slug:", checkedState: true});



--inside if userResponse = true block
set hasBleed to checked state of chkBleed
set hasSlug to checked state of chkSlug
--then add values as part of the return statement
return {projName:projectName, authName:authorName, presetIndex:presetIndex, nPages:numPages, styleIndex:styleIndex, doBleed:hasBleed, doSlug:hasSlug}


//inside if userResponse == true block
var hasBleed = chkBleed.checkedState;
var hasSlug = chkSlug.checkedState;
//then add these values as part of the return statement
return [projectName, authorName, presetIndex, numPages, styleIndex, hasBleed, hasSlug];



--Call doBleed handler if doBleed from userResponse is true
if doBleed of userResponse = true then
   addBleed(docRef, bleedSiz)
end if
--adds bleed to document
on addBleed(docRef, bleedSiz)
   tell application "Adobe InDesign CS6"
      tell document preferences of docRef
         set document bleed top offset to bleedSiz
         set document bleed uniform size to true
      end tell
   end tell
end addBleed


var bleedSiz = "12 pt";
//Call doBleed function if doBleed from userResponse is true
if (userResponse[5] == true) {
     addBleed(docRef, bleedSiz);
//adds bleed to document given size of bleed; assumes bleed uniform size is true
function addBleed (docRef, bleedSiz) {
docRef.documentPreferences.documentBleedTopOffset = bleedSiz;
docRef.documentPreferences.documentBleedUniformSize = true;


As part of creating a slug, you will want to create a text box with slug text containing information such as the name of the project and the creation date. Guides, and page marks, and slug text are generally placed on a common layer. This will require the script to designate a layer reference. The values for the variables slugSiz, slugLayer, and toBack are defined locally at the top of the script.


--call to check layer and create slug  handlers
   if doSlug of userResponse = true then
      set layerRef to checkLayer(docRef, slugLayer, toBack)
      addSlug(docRef, layerRef, slugSiz, projectName, pubDate)
   end if
--checks for layer by name; creates layer if not found
on checkLayer(docRef, layerName, toBack)
   tell application "Adobe InDesign CS6"
      tell docRef
         if not (exists layer layerName) then
            set layerRef to make layer with properties {name:layerName}
            if toBack then
               move layerRef to after layer -1
            end if
            set layerRef to layer layerName
            if (layerRef.locked is true) then
               set locked of layerRef to false
             end if
         end if
      end tell
   end tell
   return layerRef
end checkLayer
//create slug on layer referenced
on addSlug(docRef, layerRef, slugSiz, projName, daateStamp)
tell application "Adobe InDesign CS6"
   set textFramePrefs to {inset spacing:{"3 pt", "3 pt", 0,0}, text column count:1}
   tell document preferences of docRef
      set slug top offset to slugSiz
      set document slug uniform size to false
      set pageWid to page width
   end tell
   set slugTxt to projName & " " & dateStamp
   tell page 1 of master spread 1 of docRef
      set frameRef to make text frame with properties {geometric bounds:{("-" & slugSiz), 0,0,pageWid}, contents:slugTxt, text frame preferences:textFramePrefs});
   end tell
end tell
end addSlug


var slugLayer = "Furniture";
var toBack = true;
//call to checkLayer and createSlug functions
if (userResponse[6] == true) {
var layerRef = checkLayer (docRef, slugLayer, toBack);
addSlug (docRef, layerRef, slugSiz, project"Name, dateStamp);
//checks for layer by name; creates layer if not found
function checkLayer (docRef, layerName, toBack) {
   if (docRef.layers.item(layerName) == null) {
     var layerRef = docRef.layers.add({name:layerName});
     if (toBack == true) {
   }else {
     var layerRef = docRef.layers.item(layerName);
     if (layerRef.locked == true) {
          layerRef.locked = false;
   return layerRef;
//adds slug to document with text frame
function addSlug (docRef, layerRef, slugSiz, projName, dateStamp) {
   var textFramePrefs = {insetSpacing:["3 pt", "3 pt", 0, 0], textColumnCount:1};
   var docPrefs = docRef.documentPreferences;
   docPrefs.slugTopOffset = slugSiz;
   docPrefs.documentSlugUniformSize = false;
   var pageWid = docPrefs.pageWidth;
   var slugTxt = projName + " " + dateStamp;
   var pageRef = docRef.masterSpreads.item(0).pages.item(0);
   var frameRef = pageRef.textFrames.add({geometricBounds:[("-" + slugSiz),0,0,pageWid], contents:slugTxt, textFramePreferences:textFramePrefs});

As you can see using a procedural format for a script makes adding new functionality fairly simple. Once you have subroutines created to take care of the added functionality, all you need to do is call the routines from the main portion of the script. Watch for the complete script, “NewDoc_PrintwOptiosn” to be posted to the appropriate script pages of this site.