0

I need to move the text frame created in the below script to outside the page area to the bleed area. If anyone can help me adjust the below script, that would be wonderful. I have been trying to determine how to use Page Height and Width to do an X, Y adjustment once that is determined.

Please see my code below. Any and all help would be greatly appreciated and thank you in advance.

myDocument = app.activeDocument;
//The bleed and slug properties belong to the documentPreferences object.
with (myDocument.documentPreferences) {
//Bleed
documentBleedBottomOffset = "2in";
documentBleedTopOffset = "2in";
documentBleedInsideOrLeftOffset = "2in";
documentBleedOutsideOrRightOffset = "2in";
//Slug
slugBottomOffset = "0p";
slugTopOffset = "0p";
slugInsideOrLeftOffset = "0p";
slugRightOrOutsideOffset = "0p";
}
var myDocument = app.documents.item(0);
var myPage = myDocument.pages.item(0);
var myTextFrame = myPage.textFrames.add();
//Set the bounds of the text frame [x1, y1, x2, y2]
//The x1, y1 refers to the upper left coordinate position; the x2, y2 refers to the lower right coordinate
//x2 = Height and y2 = Width
myTextFrame.geometricBounds = [0, 0, .52, 5.5];
//Enter text in the text frame.
//("\r" is a return character.+
myTextFrame.contents = "FName Name//12345-6789//\r WxL//\r XXX-YYYYY//W x L-LtrRD//P_";
myTextFrame.parentStory.insertionPoints.item(-1).contents = SpecialCharacters.autoPageNumber;
//Note that you could also use a properties record to
//create the frame and set its bounds and contents in one line:
//var myTextFrame = myDocument.pages.item(0).textFrames.add({geometricBounds:[72, 72, 288, 288], contents:"This is some example text."});

//Absolute move: based on [X , Y] its important to keep in mind that all units are based on your document units
myTextFrame.move([1, 5.5]);
John D
  • 139
  • 13

2 Answers2

0

Please add the following lines of snippet that will calculate the x and y coordinate for the move parameter... As it was not mentioned where exactly the frame needs to be shifted hence shifting in the corner in the bleed.. You can use this to adjust accordingly..

var theBounds = myPage.bounds;
var theXCoord = theBounds[3] + (myDocument.documentPreferences.documentBleedBottomOffset)/2;
var theYCoord = theBounds[2] + (myDocument.documentPreferences.documentBleedBottomOffset)/2;

myTextFrame.move([theXCoord, theYCoord]);

Hope this answers your question...

Bhumi
  • 1
  • In doing the above, it places the box at the lower right corner of the document. I wanted to place the box at X= -1.5161 X= (this would be .72 below the document page). Keep in mind that the document height could change, so I need this to be able to be variable) – John D Apr 04 '17 at 22:53
0

From Bhumi's response I was finally able to figure out at I should use the myDocument.documentPreferences.pageHeight property within my move statement. This will require the move to get the height of the document.

myTextFrame.move([-1.5161, myDocument.documentPreferences.pageHeight + .72]);
John D
  • 139
  • 13