Quantcast
Channel: Adobe Community: Message List
Viewing all articles
Browse latest Browse all 114192

Re: Read .txt file and input into textFrames

$
0
0

doc = app.activeDocument;

var srcPath = doc.path +"/codes.txt" // put the codes.txt in the same folder as the .Ai file

var codeFile = new File (srcPath);

var openF = codeFile.open ("r");

if (openF) {

    var codeLines = new Array ();

    var codes = codeFile.read();

    var codeLines = codes.split("\n"); // split file by line, if you have a comma delimted file put "," instead of "\n"

    codeFile.close();

    }

alert(codeLines.length +" Codes in your Document and " +"\n" + putCode.length +" textframes to replace")

 

 

var putCode = doc.layers[0].textFrames // will put the codes in all the text frames of the top layer

for (var i = 0;i<putCode.length;i++) {  // starts on line 1 of the code.txt

    putCode[i].contents = codeLines[i];

    }


Viewing all articles
Browse latest Browse all 114192

Trending Articles



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