Tag : JavaScript
April 11, 2011 | Extras
| en
The interesting thing about tracking Scripting DOM changes from InDesign CS5 to InDesign CS5.5 is that this instantly reveals the main innovations of this ‘mid-cycle’ release —so that scripters can easily focus on the freshest features. The below PDFs offer you in a snap the tip of the iceberg: the new Article component and a bunch of new export options (HTMLExportPreference, EPubExportPreference, StyleExportTagMap, ObjectExportOption) that indicate the much greater integration of InDesign EPUB and digital publishing capabilities. Enjoy!


• See also: “So What's New in InDesign CS5 Scripting DOM”
March 07, 2011 | Snippets
| en
The InDesign Scripting Forum is an ideal place to post scripting recipes and to address technical issues. I learn a lot from its famous contributors —Dave Saunders, Harbs, Jongware, Peter Kahrel, Kasyan Servetsky, Marijan Tompa… At odd times I post my own brainchilds. Here is a small selection of snippets and topics that I think are worthwhile.
Continue reading...
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.
Continue reading...
October 02, 2010 | Extras
| en
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.
Continue reading...
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.
Continue reading...
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.
Continue reading...
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.
Continue reading...
December 23, 2009 | Extras
| en | fr
As a present for Christmas, here is a compilation of the greatest links we've tweeted during those last 3 months. An overwhelming majority regards InDesign scripting, plug-ins, GREP and/or JavaScript resources for ‘InDevelopers’.
Continue reading...
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.
Continue reading...
August 17, 2009 | YALT
| en | fr
In the previous episode, we designed a light-weighted markup syntax for localized strings of any JavaScript based projects. Now let's see how to get a generic and simple access to those L10N data.
Continue reading...
August 03, 2009 | YALT
| en | fr
When you need your script's user interface to be translated according to the InDesign application locale, the common approch is to invoke the localization ExtendScript feature. The process is pretty straightforward, except that —in a verbose UI— you will have to create and manage many “localization objects”.
Continue reading...
June 16, 2009 | Snippets
| en | fr
InDesign is definitely not a solution for web designers. For example, look at the Swatches panel, isn't it the worst tool to select or create “web colors” in the #rrggbb hexadecimal format? Fortunately, the ScriptUI elements bring a way to build our own “Web Color Picker”, interacting with the swatches.
Continue reading...
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.
Continue reading...
May 31, 2009 | Tips
| en | fr
JavaScript is often considered as a weakly typed language. It means —among other things— that we don't need to tell explicitly what kind of variables we handle, or what kind of arguments we provide to a given function. String? Integer? Boolean? In most cases, everything will work without ever declaring the type.
Continue reading...