Skip to main content

Posts

Showing posts with the label InDesign Scripting

A Simple Sample to Make Color List in InDesign

Here is a simple sample to make color list in InDesign. It is very simple, because, there are no left-right page handling, no color values for cyan, magenta, yellow and black, no page numbers, no comments, and no drawing the border of the color-box. And I don't have much time to reply any question. Please try it on your own. Here is the code: main(); function main() { if (app.documents.length == 0) { var myDocument = app.documents.add(); basicSetup(myDocument); myDocument.textFrames.item(0).remove(); makeSwatch(myDocument); } return 0; } function basicSetup(myDocument) { myDocSetup(myDocument); myMasterSpreads(myDocument); } function myDocSetup(myDocument) { with (myDocument.documentPreferences) { pageHeight = "29.8cm"; pageWidth = "21.6cm"; pageOrientation = PageOrientation.portrait; facingPages == true; documentBleedUniformSize = true; documentBleedTopOffset = "3p"; documentSlugUniformSize = true; slugTopOffset = ...

InDesign Scripting with ScriptUI: Add a TestIt Button to Play Around

Based on my previous article " InDesign Scripting with ScriptUI: How to Move Cursor and Select Text ", let's add a button to play around. The original code looks like this: // --- Last Part of UI (No Panel) --------------------------------------------- function AddCloseButton(w) { w.grpButtons = w.add('group'); w.btnClose = w.grpButtons.add('button {text: "Close"}'); w.btnClose.onClick = function () { w.close(); } } // ------------------------------------------------------- Let me add a button to select a piece of text. Below in in the listener function "TestIt", I don't add the boundary checking . You may try and modify the variables "start" and "end" to go over the boundary. And see what happens. // --- Last Part of UI (No Panel) --------------------------------------------- function AddCloseButton(w) { w.grpButtons = w.add('group'); w.grpButtons.orientation = "column"; ...

InDesign Scripting with ScriptUI: How to Move Cursor and Select Text

Based on the code pattern in my  previous article , here I’d like to show the methods to move the cursor and to select text with button click on ScriptUI. Using buttons to move cursor and to select text is useful when working with a script, which has a UI. You don’t need to move your mouse running all over the whole screen very often for doing your tasks. Most of the time, you can concentrate your mouse movement just around the UI of your script. The code is divided into 4 parts: Part 1 , from line 10 to line 28: This is the coding pattern for the modeless dialog. Part 2 , from line 37 to line 57: The main UI is created in this part. Part 3 , three groups of buttons are created here, together with the functions, which are attached to the button click event. Group 1: from line 60 to line 67, the code setups the buttons for moving cursor. from line 69 to line 118, the event listener "MoveCursor" is defined. Group 2: from line 121 to line 128, the code s...

A Programming Pattern to Create a Modeless Dialog with Adobe ScriptUI

I'd like to create a dialog box to input some special characters onto InDesign without running the dialog every time, after I clicked on some button to input characters. A modeless dialog is the choice. But I got many crashes. Finally, with the sample from Adobe, I got a stable programming pattern, which works with Adobe CC. Here is the code: #targetengine session; // the above line is necessary to create a modeless dialog with // var win = new Window("palette", ...); // // refer to the sample program from Adobe: "SnpCreateDialog.jsx". // Which is usually located at the folder (Windows): // C:\Program Files (x86)\Adobe\Adobe ExtendScript Toolkit CC\SDK\Samples\javascript function AModelessDialog() { this.windowRef = null; } function setupWindow() { var ww = new Window("palette", "A Modeless Dialog"); addComponents(ww); return ww; } AModelessDialog.prototype.run = function() { var win = setupWindow(); this.windowRef = win; w...