Posts in Category "Scripting"

Running a script from an InDesign plug-in

Perhaps you’ve come to native plug-in development from a more script-based background, or perhaps you have some existing script code you want to reuse in a new plug-in project. Whatever your background, it’s really handy to be able to run a script from a native plug-in, and it’s also surprisingly easy.

The code below works out of the box so you can copy and paste as much as you please.

#include "IScriptManager.h"
#include "IScriptEngine.h"
#include "IScriptRunner.h"
#include "IScriptUtils.h"
#include "JavaScriptID.h"

InterfacePtr<IScriptManager> scriptManager(Utils<IScriptUtils>()->QueryScriptManager(kJavaScriptMgrBoss));
if (!scriptManager)
{
   return;
}

InterfacePtr<IScriptEngine> scriptEngine(scriptManager->QueryDefaultEngine());
if (!scriptEngine)
{
   return;
}

InterfacePtr<IScriptRunner> scriptRunner(scriptEngine, UseDefaultIID());
if (!scriptRunner)
{
   return;
}

RunScriptParams params(scriptRunner);
scriptRunner->RunScript("alert('hello, world!');", params);

The above code uses JavaScript but you may use any script manager you like, including kAppleScriptMgrBoss for AppleScript and kOLEAutomationMgrBoss for Visual Basic. For a complete list of available scripting managers see ‘Script managers’ in chapter 10 ‘Scriptable Plug-in Fundamentals’ of the Programming Guide Volume 1 included in the plug-in SDK (available at http://www.adobe.com/devnet/indesign/sdk.html).

Flash UIs with InDesign CS4

InDesign user-interface development can be expensive. It takes a lot of effort to implement a dialog or panel in ODFRC. Things should improve in future versions, with the possibility of using Flash-based user-interface tools like Flex and FlexBuilder. While this represents the future direction of InDesign user-interface development, there is a present reality in InDesign CS4. With an understanding of the current situation, you can implement Flash-based user-interfaces for InDesign CS4.

Continue reading…

Scripting InDesign CS4 Preflight

We’ve received numerous requests for sample scripts that demonstrate working with the Adobe InDesign CS4 new live preflight feature. Several of these requests have come from InDesign Server partners who want to know how to use the new preflight engine. My Creative Suite Developer Technologies teammate Joe Stinson and I collaborated on the following information that we think will save you a lot of time when trying to script the new preflight feature.

If you are not familiar with preflight, please first watch this introductory video:
http://www.adobe.com/designcenter/indesign/articles/lrvid4025_id.html).

This post will demonstrate how to interact with the preflight system using JavaScript. For illustration purposes, we show how to configure preflight to raise an error if the page size is something other than letter size (8.5”X 11”). We briefly highlight how it’s done in the UI, then show how to achieve the same results through scripting.

Continue reading…