Skip to main content
Known Participant
July 10, 2022
Answered

Creating Position for PointText frame in Illustrator

  • July 10, 2022
  • 1 reply
  • 381 views

How to set the x and y  position for the PointText frame using Script

This topic has been closed for replies.
Correct answer femkeblanco
// First way, in relation to the position of the base line.  (The left of the baseline by default, but can be changed to the centre or the right of the baseline, by changing the justification.)
var x = 10, y = -10;  // example
var text1 = app.activeDocument.textFrames.pointText([x, y]);
text1.contents = "Lorem ipsum";
// text1.textRange.paragraphAttributes.justification = Justification.CENTER;

// Second way, in relation to the left top position of the text frame. 
var text2 = app.activeDocument.textFrames.pointText([0, 0]);
text2.contents = "Lorem ipsum";
text2.position = [x, y];

1 reply

femkeblanco
femkeblancoCorrect answer
Legend
July 10, 2022
// First way, in relation to the position of the base line.  (The left of the baseline by default, but can be changed to the centre or the right of the baseline, by changing the justification.)
var x = 10, y = -10;  // example
var text1 = app.activeDocument.textFrames.pointText([x, y]);
text1.contents = "Lorem ipsum";
// text1.textRange.paragraphAttributes.justification = Justification.CENTER;

// Second way, in relation to the left top position of the text frame. 
var text2 = app.activeDocument.textFrames.pointText([0, 0]);
text2.contents = "Lorem ipsum";
text2.position = [x, y];
SA8888Author
Known Participant
July 10, 2022

Thank you for the script guide, I wanted to set the position using the property (text.top) and (text.left) can you help using this property to set the position of PointText?

femkeblanco
Legend
July 10, 2022
var text2 = app.activeDocument.textFrames.pointText([0, 0]);
text2.contents = "Lorem ipsum";
text2.top = -20;
text2.left = 20;