Forum Replies Created
-
AuthorPosts
-
October 3, 2016 at 9:19 am in reply to: How to create a series of texte frame using values from txt file #88817
Kathy Cote
MemberHi,
ok I got!myFrame=newDoc.textFrames.add();
myFrame.contents = c;
myFrame.geometricBounds = [0,0,1,w];October 3, 2016 at 8:27 am in reply to: How to create a series of texte frame using values from txt file #88815Kathy Cote
MemberHi,
I try to run the following script. The script will create the new InDesign document from a .txt file. It names new files according to their sizes, save and close. It works.Before closing, I would like to create a new text frame for each of the created files with the information of the third column [2] (or variable “c”). There is indeed a new text frame but I failed to insert my text “c”. I’m sure the problem is my variable but I can’t fix it.
I have a .txt file with 3 columns et 50 lines.
someone of you have the solution?
Your help is greatly appreciated,
Kathy
This is my code:
var file = File.openDialog(“Select Your Text File”, undefined, false);
var folder = Folder.selectDialog(“Select the folder where the new documents should be saved”);
file.open(“r”);
var content = file.read().split(“”);
var pageIndex;for (var i = 0; i < content.length ; i++) {
var curLine = content[i].split(“”);
var w = curLine[0];
var h = curLine[1];
var c = curLine[2];docName = w + “X” + h + “_” + c ;
try {
var newDoc = app.documents.add(false);
newDoc.documentPreferences.pageHeight = h;
newDoc.documentPreferences.pageWidth = w;newDoc.save(new File(folder + “/” + docName + “.indd”));
if (pageIndex==undefined)pageIndex=0;
var newTextFrame=newDoc.pages[pageIndex].textFrames.add();
newTextFrame.newDoc=c; //it does not worknewDoc.close(SaveOptions.no)
} catch(myError){}
}September 30, 2016 at 10:26 am in reply to: How to create a series of texte frame using values from txt file #88756Kathy Cote
MemberHi,
I usually use the data merge but it is a bit complicated if I want to use data merge with 50 different document formats.I have a script that can create all my new Indesign documents with a .txt file. In those new documents, I want to create multiple automatic text frame.
Thanks ;-)
Kathy
Kathy Cote
Memberok everyone, I’m sorry. I saw my error.
Everything works well!Thanks
Kathy Cote
MemberI try to modify the code but it seems to be a problem.
I would use a .txt file with 3 columns and to use numbers with decimals.
Ok I added the code to the 3 columns but I do not know how to modify the code to use numbers with decimals. And my other problem is that the script seems to only read the first line in the .txt file. The script does not give me an error but does not work completely.does anyone know?
Example of my text in the .txt file:
33 66 1569
55 22 1256
5.5 10.5 8956
33.5 33.5 5842
33.5 33.5 9856and this is my code:
var file = File.openDialog(“Select Your Text File”, undefined, false);
var folder = Folder.selectDialog(“Select the folder where the new documents should be saved”);
file.open(“r”);
var content = file.read().split(“”);for (var i = 0; i < content.length – 1; i++) {
var curLine = content[i].split(“”);
var w = curLine[0];
var h = curLine[1];
var c = curLine[2];docName = w + “X” + h + “_” + c ;
try {
var newDoc = app.documents.add(false);
newDoc.documentPreferences.pageHeight = h;
newDoc.documentPreferences.pageWidth = w;
newDoc.save(new File(folder + “/” + docName + “.indd”));
newDoc.close(SaveOptions.no)
} catch(myError){}
}Kathy Cote
MemberHi Peter,
I just want to say thank you. That script is amazing!Kathy Cote
MemberHi Ari,
I want to say thank you, it works! WOW!The only thing is, I can only use whole numbers. I would like to be able to use example: 45.5 X 45.5
Is it possible ?
Thanks ;-)
Kathy Cote
MemberHi,
I have bilingual flyers. Sometimes the french text is in first and the English text is after the French. But I have to do another version of this flyer, but with English text in first, and the French after the English.Kathy Cote
MemberSo nice, thank you!
Kathy Cote
MemberAmazing ! It works very well! thanks you so much! Thanks you all!
Kathy Cote
MemberHi,
I would like to change the horizontal and vertical margins pasteboard in the preferences (not the margins in the page).Kathy Cote
MemberHi Ari,
Thank you very much for your help. I really appreciate.
I only have a small problem with the script. I can not make it work.
I was wondering if you could help me with that ?This is the JavaScript Error:
Error Number: 25
Error String: Expected: )Engine: main
Line: 7
Source: for (var i = 0; i < content.length – 1; i++) {Offending Text: ;
Again thank you for everything ;-)
Kathy
Kathy Cote
MemberThank you to everyone for your help! it works great!
Kathy Cote
Memberoh wow it works! Thanks a lot! I really appreciate your help.
I have one more question …
Sometimes I have documents with one page and others with multiple pages. If it is a document with multiple pages, do you know if it’s possible to export all page, per page for all open documents?Thanks
Kathy Cote
Memberoh you’re so nice !
Thanks a lot!
-
AuthorPosts
