I have following code. My script can read external file liken(txt) and place it to InDesign file but if I try to change .txt --> .doc I get some weird characters It looks like .js or .jsx doesn't know to read it What I can do in this case?
this works
var variable ="hello world"
var doc = app.activeDocument;
var titleTextFrame = doc.textFrames.add();
titleTextFrame.contents = variable;
titleTextFrame.geometricBounds = [20, 80, 80, 150];
var inputFile = File("~/Desktop/text.txt");
var inputData;
inputFile.open("r");
inputData = inputFile.read().toString();
inputFile.close();
alert(inputData);
var textLorem = doc.textFrames.add();
textLorem.contents = inputData;
textLorem.geometricBounds = [30, 80, 80, 150];
this doesn't work
var inputFile = File("~/Desktop/text.doc");
If you want to place files like DOC, etc you have to use method place(file)
:
var variable ="hello world"
var doc = app.activeDocument;
var titleTextFrame = doc.textFrames.add();
titleTextFrame.contents = variable;
titleTextFrame.geometricBounds = [20, 80, 80, 150];
var inputFile = File("~/Desktop/text.doc");
var textLorem = doc.textFrames.add();
textLorem.geometricBounds = [30, 80, 80, 150];
textLorem.place(inputFile); // <-------------------- here
It doesn't make sense to read DOC files directly with file.read()
method.