Hi
I am new in indesign scripting
I want to create indesign Application using java script and without using ExtendScript ToolKit
In this case how create app (the application object).
if i use ExtendScript ToolKit then there is no need to create application object. app is bydefault
But i do not want to use of ExtendScript ToolKit .
I want to create simple java script using
<script type="text/javascript">
//body
</script>
when i run my java script (.js) file then it create indesign Application (instance).
For example on mac in Apple Script when i run my apple script
tell application "Adobe InDesign CS5.5"
set myDocument to make document with properties
end tell
in apple script editor which is inbuild with mac, Indesign Application start(create) sucessfully.
There is no need any ExtendScript ToolKit type tool to run (start) indesign application.
only script line tell application "Adobe InDesign CS5.5" create application instance.
In VBScript we create application object using this :
| VBScript | : | Set myInDesign = CreateObject("InDesign.Application") |
In Java Script how create Indesign Application Object.
I try to create Indesign Application object but not sucess.
<!DOCTYPE HTML>
<html>
<head>
<title>Testing JavaScript</title>
</head>
<body>
<script type="text/javascript">
var app = CreateObject("InDesign.Application");
var myDocument = app.documents.add();
var myTextFrame = myDocument.pages.item(0).textFrames.add();
myTextFrame.geometricBounds = ["6p", "6p", "24p", "24p"];
myTextFrame.contents = "Hello World!";
</script>
</body>
</html>
How create Indesign application Object using JavaScript ?
Thanks Harbs for reply
Plz give me a simple .js example which run without ExtendScript ToolKit and create Indesign Application and one textframe in it.
if I save below script as .js extention and run it after double click on it then it give undefined app error.
<script type="text/javascript">
var app = CreateObject("InDesign.Application");
var myDocument = app.documents.add();
var myTextFrame = myDocument.pages.item(0).textFrames.add();
myTextFrame.geometricBounds = ["6p", "6p", "24p", "24p"];
myTextFrame.contents = "Hello World!";
</script>
I want to create indesign application using java script but do not want to use ExtendScript ToolKit.
Thanks.
What do you mean by not using ExtendScript Toolkit? The ESTK is not required. Script files are saved as plain text inside your Script Panel folder and run from the script panel.
Like I said, there's no need to define "app". Here is the full correct version of your script:
var myDocument = app.documents.add();
var myTextFrame = myDocument.pages.item(0).textFrames.add();
myTextFrame.geometricBounds = ["6p", "6p", "24p", "24p"];
myTextFrame.contents = "Hello World!";
Are you trying to run the script from outside InDesign?
Thanks Harbs for reply
Yes I want to run the script from outside Indesign.
For example on Mac os i use appleScript editor to run appleScript
tell application "Adobe InDesign CS5"
set myDocument to make document
end tell
My Indesign application start sucessfully.
I want to simply run my java script and want to create Indesign Application.
I do not want to put my script in Script Panel folder.
Like on Mac os , i want to create on window os using java script.
Simple run script in any java script editor (except ExtendScript ToolKit) and create Application.
Is it possible ?
Thanks
That's NOT quite correct Harb's… You head the script with the #target and you can double click it in the UI see Toolkit:
#target name Defines the target application for this JSX file. The name value is an application specifier; see Application and namespace specifiers. Enclosing quotes are optional.
If the Toolkit is registered as the handler for files with the .jsx extension (as it is by default), opening the file opens the target application to run the script. If this directive is not present, the Toolkit loads and displays the script. A user can open a file by double-clicking it in a file browser, and a script can open a file using a File object’s execute method.
As of either CS4 or CS5 you need to put the script in a TRUSTED place… on the mac
~/Documents/Adobe Scripts/YourScript.jsx // Then just alias it from that…
Harb's I think you misunderstood me… Head the file with #target indesign not the ESTK… Your snippet plus this will launch Indesign if NOT running and will execute without opening the ESTK
#target indesign
var myDocument = app.documents.add();
var myTextFrame = myDocument.pages.item(0).textFrames.add();
myTextFrame.geometricBounds = ["6p", "6p", "24p", "24p"];
myTextFrame.contents = "Hello World!"
Thanks for Reply
When I tried this I got a Script Aleart message.
"You are about to run a script in Adobe indesign CS5.5. You should only run script from a trusted source.Do you want to run the script" Yes, No.
when I click on yes then Indesign application start sucessfully and create a text frame with Hello World!.If I click on No then Script open in ExtendScript ToolKit.
I want to skip (or hide) this Script Aleart message and run the script directly without prompt this Aleart message. How hide this Script Aleart message ?
Thanks Mark for reply
I put my script at Trusted location C:\\Documents and Settings\\Administrator\\My Documents\\Adobe Scripts\\NewSript.jsx
Now I want to execute my script using below method but it not execute and return message "No documents open".
#include "indesign.h"
INDESIGN::_Application oApplication;
if(oApplication.CreateDispatch(L"InDesign.Application") ==0) // it start Indesign Application
{
// Dispatch is not created
}
CString ScriptPath =L"C:\\Documents and Settings\\Administrator\\My Documents\\Adobe Scripts\\NewSript.jsx";
oApplication.DoScript(COleVariant(ScriptPath),long(1246973031),covOpti onal,long(1699967573),ScriptPath);
It prompt message "No document open". While I double click on NewScript.jsx it run sucessfully.
General syntex of oApplication.DoScript() is
any doScript (script: varies[, language: ScriptLanguage=ScriptLanguage.UNKNOWN][, withArguments: Array of any][, undoMode: UndoModes=UndoModes.SCRIPT_REQUEST][, undoName: string=Script])
Executes the script in the specified language as a single transaction.
I use long(1246973031) for The java script language.
I do not understand where is problem.
my .jsx file data is
var myDocument = app.activeDocument;
var myTextFrame = myDocument.pages.item(0).textFrames.add();
myTextFrame.geometricBounds = ["6p", "25p", "30p", "30p"];
myTextFrame.contents = "Adobe Indesign !"
Thanks
North America
Europe, Middle East and Africa
Asia Pacific