Skip to main content
Participating Frequently
November 2, 2023
Answered

Auto add text to a path

  • November 2, 2023
  • 2 replies
  • 1549 views

Hi . we have lots of text box that we need to use Type On Path tool and add them on some curved lineds, 
Is it possible to use Scripting for this?

I mean when i select both a text box and a line(drawed by Pen tool)(Screenshot_1) , and then Run the Script, it automaticlly put the text from the text box  using  the type on path tools on the cureved line(Screenshot_2)

This topic has been closed for replies.
Correct answer GNDGN

The paragraph style method is the easier one. Just append this line to the script above:

tp.texts[0].appliedParagraphStyle = doc.paragraphStyles.item("myParStyle");

Make sure to replace myParStyle with the actual paragraph style name.

2 replies

Peter Kahrel
Community Expert
Community Expert
November 5, 2023

That line I gave replaces the last line in GNDGN's script.

Participating Frequently
November 6, 2023

i replace the line you gave with the last line in it is working. no need to apply paragraph style anymore. thanks

GNDGN
Inspiring
November 2, 2023

This does the job:

var doc = app.activeDocument;
var tf;
var path;

if(String(doc.selection[0]).indexOf("Polygon") > -1) {
	path = doc.selection[0];
	tf = doc.selection[1];
} else {
	tf = doc.selection[0];
	path = doc.selection[1];
}

var tp = path.textPaths.add();
tp.contents = tf.contents;

Prior to script execution, you need to select one curved line and one text frame.

 

Before:

 After:

 

____________________Robotic Process Automation in Desktop Publishing (Book): https://doi.org/10.1007/978-3-658-39375-5
Participating Frequently
November 2, 2023

I tested the code and it is functioning correctly. Nice work!