Skip to main content
Known Participant
May 4, 2023
Answered

graphic line

  • May 4, 2023
  • 3 replies
  • 1036 views

Dear all,

   How to draw a graphic line above a specific text frame in Adobe InDesign using scripting

 

Thanks in advance

This topic has been closed for replies.
Correct answer rob day

Hi @John_devs , Select a text frame and try this:

 

 

app.scriptPreferences.measurementUnit = MeasurementUnits.POINTS;
var tf = app.documents[0].selection[0];
var b = tf.geometricBounds;
var p = tf.parentPage;
var g = 5;//gap above frame in points
p.graphicLines.add({geometricBounds: [b[0]-g, b[1], b[0]-g, b[3]], strokeColor:"Black", strokeWeight:1});

app.scriptPreferences.measurementUnit = AutoEnum.AUTO_VALUE;

 

 

Before:

 

After:

3 replies

Willi Adelberger
Community Expert
Community Expert
May 4, 2023

Why do you want to script it, use paragraph styles. 

Loic.Aigon
Legend
May 4, 2023

or script those but indeed.

rob day
Community Expert
rob dayCommunity ExpertCorrect answer
Community Expert
May 4, 2023

Hi @John_devs , Select a text frame and try this:

 

 

app.scriptPreferences.measurementUnit = MeasurementUnits.POINTS;
var tf = app.documents[0].selection[0];
var b = tf.geometricBounds;
var p = tf.parentPage;
var g = 5;//gap above frame in points
p.graphicLines.add({geometricBounds: [b[0]-g, b[1], b[0]-g, b[3]], strokeColor:"Black", strokeWeight:1});

app.scriptPreferences.measurementUnit = AutoEnum.AUTO_VALUE;

 

 

Before:

 

After:

John_devsAuthor
Known Participant
May 5, 2023

Thanks a lot it helped so much.

i need one more assisstance:

i need to draw graphiclines to a particularaly one textframe in each page when i run the script 

Robert at ID-Tasker
Legend
May 5, 2023

How script should know which TextFrame? 

 

Participating Frequently
May 4, 2023

Hi John_devs!
I think you need to explain the user case a little more in detail so we can give you a hand.