Hi,
I have a script that adds new text boxes into new documents. I would like to be able to place the boxes text 2 and 3 in the right place in the page but it does not work. I need your help.
Thanks again for your help
1st text box: OK
**
Here part of my code:
//—- 2nd tx box = I would like the 2nd box of text to be aligned in the page to the right and bottom.
//How to program: align page, right-bottom?
myFrame2=newDoc.textFrames.add();
myFrame2.contents = H;
var Y2 = 0; //Y
var X2 = 1; //X
var H2 = 5; //Height
var L2 = D; //Width
myFrame2.geometricBounds = [Y2, X2, H2, L2]; //Y, X, Height, Width
//—- End 2nd box
//—- 3nd tx box – I would like the top of the 3rd box to be placed in the bottom slug which is actually the L3.
myFrame3=newDoc.textFrames.add();
myFrame3.contents = C + (“\r”) + (“”) + D + “in” + ” X ” + E + “in” + (“\r”) + (“”) + A + ” ” + “Photo: ” + J;
var Y3 = E+H3; //Y3. – I would like the top of the 3rd box to be placed in the bottom slug. I think Y3 should be H3 + E (Page Height) but it does not work.
var X3 = 0; //X
var H3 = 5; //Height
var L3 = D; //Width
myFrame3.geometricBounds = [Y3, X3, H3, L3]; //Y, X, Height, Width
//—- End 3 box
**
//Here my entire code
//Create New Document from txt file
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 A = curLine[0];
var B = curLine[1];
var C = curLine[2];
var D = curLine[3];//Width
var E = curLine[4];//Height
var F = curLine[5];
var G = curLine[6];
var H = curLine[7];
var J= curLine[8];
var K = curLine[9];
var L= “A117061”;
//Indd name
docName = L + “_” + B + “_” + H + “_” + A + “_” + G + “_” + D + “X” + E;
try {
var newDoc = app.documents.add(false);
//— Set the document size
newDoc.documentPreferences.pageWidth = D;
newDoc.documentPreferences.pageHeight = E;
//—- 1st tx box = OK
myFrame=newDoc.textFrames.add();//New tx box
myFrame.contents = K + ” ” + G + (“\r”) + H ;
myFrame.geometricBounds = [-5,0,0,D];
//—- End 1st box
//—- 2nd tx box = I would like the 2nd box of text to be aligned in the page to the right and bottom.
myFrame2=newDoc.textFrames.add();
myFrame2.contents = H;
var Y2 = 0; //Y
var X2 = 1; //X
var H2 = 5; //Height
var L2 = D; //Width
myFrame2.geometricBounds = [Y2, X2, H2, L2]; //Y, X, Height, Width
//—- End 2nd box
//—- 3nd tx box – I would like the top of the 3rd box to be placed in the bottom slug which is actually the L3.
myFrame3=newDoc.textFrames.add();
myFrame3.contents = C + (“\r”) + (“”) + D + “in” + ” X ” + E + “in” + (“\r”) + (“”) + A + ” ” + “Photo: ” + J;
var Y3 = E+H3; //Y3. – I would like the top of the 3rd box to be placed in the bottom slug which is actually the L3. I think Y3 should be H3 + E (Height) but it does not work
var X3 = 0; //X
var H3 = 5; //Height
var L3 = D; //Width
myFrame3.geometricBounds = [Y3, X3, H3, L3]; //Y, X, Height, Width
//—- End 3 box
//—- Change name layer
app.documents[0].layers.item(‘Layer 1’).name = ‘Slug’;
//—- Fin Change name layer
//—- Add new layer
app.documents[0].layers.add ({name: ‘Artwork’}).move(LocationOptions.AT_BEGINNING);
//—- Fin Add new layer
//—- Add new layer
app.documents[0].layers.add ({name: ‘Printer_Code’}).move(LocationOptions.AT_BEGINNING);
//—- Fin Add new layer
newDoc.save(new File(folder + “/” + docName + “.indd”));
newDoc.close(SaveOptions.no)
} catch(myError){}
} //Fin Try