Quantcast
Channel: Adobe Community : Popular Discussions - Illustrator Scripting
Viewing all articles
Browse latest Browse all 12845

Placing a text file into Illustrator

$
0
0

Hi everyone

 

So I found out how to place an image into illustrator via scripting with javascript, however I am having difficulties with text files. My code is:

 

var myDoc = app.activeDocument;

var Layer1 = myDoc.layers[0];

function getTextFile() {

    return File.openDialog('Please select the text file to be imported:', undefined, undefined);

}

var myTextfile = getTextFile();

var myPlacedFile = Layer1.placedItems.add();

myPlacedFile.file = myTextfile;

 

But when I select a text file, it says it is an unsupported format. I'm assuming it has something to do with the extra options that come with importing a text document, specific for .txt and .doc for example. Has anyone had any success with this?

 

For what it's worth I was working on an alternate method by read() ing in the contents of the .txt file and setting them equal to the contents of a textFrame, however it imported the text without carriage returns/newlines and I haven't been able to result that issue.

 

Any assistance on the matter would be greatly appreciated!

 

Thanks. Sean


Viewing all articles
Browse latest Browse all 12845

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>