Skip to main content
This topic has been closed for replies.
Correct answer Gustavo Del Vechio

Hi Prails
This script is basically what you asked:

#target illustrator

#targetengine main

function copyText(){

    var textFile = File.openDialog ("Select the file");

    if (! textFile.exists || app.documents.length==0){

        return;

    };

    textFile.open("r");

    var txtContent = textFile.read();

    textFile.close();

   

    var doc = app.activeDocument;

    var textItem = doc.textFrames.add();

    textItem.contents = txtContent   

};

copyText ();

Basically what you need to do is declare the text file, open it, read the content and close it. Then, you create a new text item in the Illustrator document and write the content once catched into the text item.

You could continue to work with the variable "textItem" in my example script if you want to set properties like the size, color of the text, position and so on. Also, if you want, replace the first line of the function var textFile = new File ("~/Desktop/Test.txt"); by var textFile = File.openDialog ("Select the file"); so the scripts opens a dialog to ask you the file you want the copy the content.

Hope to be helped

Best Regards

Gustavo

Message was edited by: Gustavo Del Vechio

1 reply

Gustavo Del VechioCorrect answer
Inspiring
October 17, 2013

Hi Prails
This script is basically what you asked:

#target illustrator

#targetengine main

function copyText(){

    var textFile = File.openDialog ("Select the file");

    if (! textFile.exists || app.documents.length==0){

        return;

    };

    textFile.open("r");

    var txtContent = textFile.read();

    textFile.close();

   

    var doc = app.activeDocument;

    var textItem = doc.textFrames.add();

    textItem.contents = txtContent   

};

copyText ();

Basically what you need to do is declare the text file, open it, read the content and close it. Then, you create a new text item in the Illustrator document and write the content once catched into the text item.

You could continue to work with the variable "textItem" in my example script if you want to set properties like the size, color of the text, position and so on. Also, if you want, replace the first line of the function var textFile = new File ("~/Desktop/Test.txt"); by var textFile = File.openDialog ("Select the file"); so the scripts opens a dialog to ask you the file you want the copy the content.

Hope to be helped

Best Regards

Gustavo

Message was edited by: Gustavo Del Vechio

Inspiring
October 17, 2013

Awesome! Yea this was exaclty what I was looking for really simple and straight forward.

Thanks man!