For obscure reasons ExtendScript 3.x is somewhat allergic to the character "\x00"
(U+0000). Some String
and RegExp
routines become silently defective as soon as your source string contains one or more NUL character. Although most of these bugs have been fixed in CS5 (ExtendScript 4.1), this still leads to compatibility and portability issues. Here is a snippet that allows to split any string and get proper results in all versions.
Tips
Scripters corner: howtos, tips and tricks (InDesign ExtendScript).Making String.split() support U+0000 in ExtendScript CS4
January 31, 2013 | Tips | en
How to Augment and Process Nested Groups (CS4-CS6)
October 22, 2012 | Tips | en
Dealing with groups is a major headache for InDesign scripters. On one hand, the Group
object has no injection method to offer, which makes difficult to append existing page items into a given group. On the other hand, although the Groups
API exposes a promising add()
method, nobody has ever managed to use this feature from any PageItem.groups
area, so we seem doomed to perpetually rebuild groups from scratch.
The Shortest-Ever Aphorism Generator
September 12, 2012 | Tips | en
As an InDesign scripter, you probably know that PageItems
, Paragraphs
—or any other collection—exposes a method named anyItem()
which randomly digs up a sample in the set. The only question is: what the hell can it be used for?
ScriptUI Fonts Facts
June 02, 2012 | Tips | en
Skinning a user interface with ScriptUI may be tricky as soon as you want to apply custom fonts to specific fields or controls. Besides the ScriptUI object model does not offer intuitive solutions to that purpose, we also have to cope with a few cross-platform issues…
How to Detect a “Ghost Item”
October 20, 2011 | Tips | en | fr
A “ghost item” is an anchored / inline page item (text frame, spline item, etc.) which is temporarily hidden because its parent character is in an overset area:
What Exactly is a Word?
September 04, 2011 | Tips | en
A number of InDesign scripts manipulate words for counting, indexing, or other processing purposes. Given a text container—basically a Story
—the InDesign Scripting DOM provides many ways to handle text contents through specialized subclasses of the Text
interface: one can easily access to insertion points, character ranges, lines, paragraphs, text columns, styled-text chunks, and… words. Although this concept seems pretty straightforward, I tried to understand a bit better what it really means.
Notes on ‘fastEntireScript’ Undo Mode
August 22, 2011 | Tips | en
In April 2009, Thomas Silkjær reported a bug on app.doScript
that alters the ‘undo’ feature in InDesign. Although this issue has been fixed in CS5, there are still some pitfalls to beware of when you want to speed up your script through fastEntireScript
…
Comparing the Performance of ExtendScript Snippets
June 23, 2011 | Tips | en
Although jsPerf is a very effective tool in a pure JavaScript environment, you may want to benchmark competing code snippets in the specific ExtendScript field. Here is a simple way to test and improve your InDesign scripted functions…
Permutation d'objets dans InDesign (miniscript)
April 19, 2011 | Tips | fr
Non sans témérité, Stéphane Baril et David Deraedt nous ont récemment accueillis sur le plateau de Chips & Tips, la célèbre série d'Adobe TV dédiée à la diététique productivité. Au détour de cet épisode, Loïc Aigon et votre serviteur proposons une sorte de préambule aux techniques d'automatisation et de scripting dans la Creative Suite, avec quelques illustrations simples et directement accessibles aux néophytes. Vous y découvrirez notamment la version embryonnaire du script SwapItems utilisé pour permuter des objets dans une maquette InDesign…
How to Implement a Basic Action Listener in InDesign
January 04, 2011 | Tips | en
While Photoshop has a handy Actions panel that gives you the ability to record and playback simple operations, InDesign provides no way —without scripting!— to automate those daily repetitive tasks. But, hey!, why not use a script to mimic such action manager? This is my very first step in that direction...
Alphabetical Sort in JavaScript (and InDesign)
October 26, 2010 | Tips | en | fr
Surprisingly, JavaScript offers no easy way to alphabetize words in relevant order. Although the Array.sort() method is known to perform, by default, a lexicographical sort, you will find very quickly that the result is wrong in most real-life situations. Actually, the internal mechanism of JS sorting is confined to compare Unicode characters by their code points, so 'Z' (U+005A) comes before 'e' (U+0065), which itself comes before 'ç' (U+00E7), etc. Also, you have all noted with vexation that InDesign does not offer any alphabetical sort feature! Here is an experimental tool to help restore order in Latin alphabets.
On ‘everyItem()’ – Part 2
July 19, 2010 | Tips | en
In the previous episode we learned that every scripting DOM object is in fact an object specifier, which acts like a path in the InDesign object tree. Collection's methods only allow us to build object specifiers. Invoking a property or a method provided by a specifier causes InDesign to send a “verb-first command” to the underlying receiver(s). We will now consider how this process impacts your code, what is returned into your script and how to deal with some side effects.
On ‘everyItem()’ – Part 1
June 30, 2010 | Tips | en
Every collection in the scope of the InDesign Scripting DOM provides a method called everyItem
. It remained undocumented until InDesign CS3, but scripting experts such as Dave Saunders had already pointed out its forcefulness and already knew how to exploit it. Here are some details about this esoteric syntax.
Operator Overloading with ExtendScript
May 25, 2010 | Tips | en
Operator overloading in JavaScript is a controversial issue. Actually, this dangerous feature has been rejected in ECMAScript 4. However, ExtendScript allows you to override the behavior of many mathematical and logical operators on a class-by-class basis since CS2.
Binary JavaScript Embedment (CS4/CS5)
April 13, 2010 | Tips | en
The jsxbin format (“Binary JavaScript”) is a boon for developers because it enables them to distribute a script without exposing its precious code. The ExtendScript ToolKit (ESTK) offers an Export to Binary feature which instantly converts a human-readable js(x) file into jsxbin. InDesign can then interpret this file as if it were a pure JavaScript. The only (boring!) problem is that the encoded script is not allowed to load a persistent session through the #targetengine
directive. Here is a secret trick to bypass this limitation with a single encrypted file.
Can InDesign Script Rewrite Itself?
November 06, 2009 | Tips | en | fr
As illustrated by the YALT technique, it's easy —and powerful!— to let a script read its own bytes while it is running. We could even go further and get a script to update itself to achieve some advanced functionalities.
Work Around the Width/Height Gap
October 17, 2009 | Tips | en
Believe me or not, the InDesign DOM can't return directly the width and the height of a page item frame! Scripting beginners may be confused about this gap. There are many pitfalls to be aware of when we deal with dimensions and units. Let's talk about bounds and coordinate spaces...
How to Quickly Test a Sample Code
June 10, 2009 | Tips | en | fr
Sometimes you just need to test a short snippet without having to create and install a complete script. Suppose you want to check some object properties, or to evaluate a simple JavaScript expression. It is easy to write and interprete your instructions from the ExtendScript Toolkit, but it would be even faster to do the whole job from the InDesign user interface.
« previous entries - Page 2 of 3 - next entries »