Skip to main content
Known Participant
March 12, 2018
Question

how script create text frame ?

  • March 12, 2018
  • 3 replies
  • 11905 views

hi .

i want script to create text frame into indesign.

This topic has been closed for replies.

3 replies

Jongware
Community Expert
Community Expert
March 13, 2018

This is described in the InDesign Scripting Tutorial. You may want to start by reading that.

See p. 9 and onwards under "Your first InDesign script".

Community Expert
March 12, 2018

Hi shahriara7551080 ,

would you please tell us what should be the Scripting language you like to use.

Regards,
Uwe

Known Participant
March 12, 2018

extendscript

java script

Community Expert
March 12, 2018

Here an example where also a new document is added:

var doc = app.documents.add();

var textFrame = doc.textFrames.add();

textFrame.properties =

{

    geometricBounds : [ 0,0,100,100 ],

    strokeWidth : 0,

    fillColor : "None",

    contents : "Hello World!"

};

Another one that is working with the active document:

var doc = app.activeDocument;

var textFrame = doc.pages[0].textFrames.add();

textFrame.properties =

{

    geometricBounds : [ 0,0,100,100 ],

    strokeWidth : 0,

    fillColor : "None",

    contents : "Hello World!"

};

Yet another example that is working with an open document with the index 0 :

var doc = app.documents[0];

var textFrame = doc.spreads[0].pages[0].textFrames.add();

textFrame.properties =

{

    geometricBounds : [ 0,0,100,100 ],

    strokeWidth : 0,

    fillColor : "None",

    contents : "Hello World!"

};

Note, that you could address the document, a spread or a page for adding the text frame.

In case of document, the first spread is addressed automatically.

Properties could be also added when using method add() :

var doc = app.documents[0];

var textFrame = doc.spreads[0].textFrames.add

(

    {

        geometricBounds : [ 0,0,100,100 ],

        strokeWidth : 0,

        fillColor : "None",

        contents : "Hello World!"

       

        // Add other property/value pairs if you like.

        // To see what's available see DOM documentation.

        // e.g. here: http://www.jongware.com/idjshelp.html

        // or: https://www.indesignjs.de/extendscriptAPI/indesign13/#about.html

    }

);

Regards,
Uwe

Steve Werner
Community Expert
Community Expert
March 12, 2018

Moving (again) to InDesign Scripting