Skip to main content
Known Participant
June 20, 2022
Answered

How to create PathText for Ellipse?

  • June 20, 2022
  • 2 replies
  • 435 views

How can we create PathText for Ellipse shape and Rectangle shape Using Script?

This topic has been closed for replies.
Correct answer femkeblanco

 

var contents = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."
var idoc = app.activeDocument;
var rect = idoc.pathItems.rectangle(-10, 10, 100, 100);
var tframe1 = idoc.textFrames.pathText(rect, 0.5, 3.5);  // startTValue = 0.5, endTValue = 3.5
tframe1.contents = contents;
// fit text to path
while(tframe1.lines[0].characters.length < tframe1.characters.length) {
    tframe1.textRange.characterAttributes.horizontalScale--;
}
var ellips = idoc.pathItems.ellipse(-130, 10, 100, 100);
tframe2 = idoc.textFrames.pathText(ellips, 0.5, 3.5);  // startTValue = 0.5, endTValue = 3.5
tframe2.contents = contents;
// fit text to path
while(tframe2.lines[0].characters.length < tframe2.characters.length) {
    tframe2.textRange.characterAttributes.horizontalScale--;
}

 

 

2 replies

femkeblanco
femkeblancoCorrect answer
Legend
June 20, 2022

 

var contents = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."
var idoc = app.activeDocument;
var rect = idoc.pathItems.rectangle(-10, 10, 100, 100);
var tframe1 = idoc.textFrames.pathText(rect, 0.5, 3.5);  // startTValue = 0.5, endTValue = 3.5
tframe1.contents = contents;
// fit text to path
while(tframe1.lines[0].characters.length < tframe1.characters.length) {
    tframe1.textRange.characterAttributes.horizontalScale--;
}
var ellips = idoc.pathItems.ellipse(-130, 10, 100, 100);
tframe2 = idoc.textFrames.pathText(ellips, 0.5, 3.5);  // startTValue = 0.5, endTValue = 3.5
tframe2.contents = contents;
// fit text to path
while(tframe2.lines[0].characters.length < tframe2.characters.length) {
    tframe2.textRange.characterAttributes.horizontalScale--;
}

 

 

CarlosCanto
Community Expert
Community Expert
June 20, 2022
var idoc = app.activeDocument;
var rect = idoc.pathItems.rectangle (-10, 20, 80, 50); // top, left, width, height
var tframe = idoc.textFrames.areaText (rect);

tframe.contents = "Lorem \nIpsum";

var ellips = idoc.pathItems.ellipse (-80, 20, 80, 50);
tframe = idoc.textFrames.areaText (ellips);

tframe.contents = "Lorem \nIpsum";
SA8888Author
Known Participant
June 20, 2022

Hey Carlos Thank you for the script, I wanted to create PathText using startTValue and endTValue for Ellipse and Rectangle.

CarlosCanto
Community Expert
Community Expert
June 20, 2022

Hi, show a screenshot of what you're refering to please