Back

If your email is not recognized and you believe it should be, please contact us.

  • You must be logged in to reply to this topic.Login

Position new text boxes

Tagged: , ,

Return to Member Forum

  • Author
    Posts
    • #90174
      Kathy Cote
      Member

      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

    • #90218
      Peter Kahrel
      Participant

      You can use the bounds property of the page. It compares with a frame’s geometricBounds. To place a box (200 wide, 75 high) at the bottom-right of the first page of a document, do this:

      width = 200;
      height = 75;
      pageBounds = app.documents[0].pages[0].bounds;
      app.documents[0].textFrames.add ({geometricBounds: [pageBounds[2]-height, pageBounds[3]-width, pageBounds[2], pageBounds[3]]});

      Peter

    • #90358
      Kathy Cote
      Member

      Hi,
      I trying place my text box on slug in the bottom of page. I can do it. Can you help me?

      Thanks again.

      My part of code:

      width = D;
      height = E;

      myFrame2=newDoc.textFrames.add();

      myFrame2.contents = H;

      //Top, Left, Bottom, Right
      var Bleed2 = “0.25”;
      var Slug2 = “0.5”;

      var Y2 = E+Bleed2; //Top
      var X2 = 0; //Left
      var H2 = E+Slug2; //Bottom
      var L2= D; //Right

      myFrame2.geometricBounds = [Y2, X2, H2, L2];

    • #90514
      Kathy Cote
      Member

      Ok I got it! I have use parseFloat.

      var width = D;
      var height = parseFloat(E);

      myFrame2=newDoc.textFrames.add();
      myFrame2.contents = H;

      //Top, Left, Bottom, Right
      var Y2 = E; //Top
      var X2 = 0; //Left
      var H2 = height+5; //Bottom. 5 if my slug
      var L2= D; //Right

      myFrame2.geometricBounds = [Y2, X2, H2, L2];

      Thanks

Viewing 3 reply threads
  • You must be logged in to reply to this topic.
Forum Ads