Skip to main content
Inspiring
May 5, 2010
Question

getting geometric bounds of each textframe of each page

  • May 5, 2010
  • 1 reply
  • 1015 views

Hi all,

I am trying to get the geometric bounds of each text frame of each page on whole document. Below is the snippet of my script. All seems to be fine earlier but as soon as I did some changes (and why I did) it seems I cannot iterate frames page by page and it stricts to 1st page instead of going on each page. Can anybody tell me what could possibly wrong:

// Error here var top_Bound = Text_FRAME.geometricBounds[0];

 

 

var myTotalPage = myDoc.pages.length;

//alert("Total Pages in current document is " +myTotalPage);

 

//var pageItems = myDoc.pages.allPageItems;

//alert ("All Page Items is "+ pageItems)

for (var i=0;i<=myTotalPage;i++)

{

var totalTextFrames = myDoc.pages.textFrames.length;

//alert ("Total Text Frames on page are "+ totalTextFrames)

 

for (var t=0;t<=totalTextFrames;t++)

{

var Text_FRAME = myDoc.pages.textFrames;

//getting error here

var top_Bound = Text_FRAME.geometricBounds[0];

var left_Bound = Text_FRAME.geometricBounds[1];

var bottom_Bound = Text_FRAME.geometricBounds[2];

var right_Bound = Text_FRAME.geometricBounds[3];

 

//alert ("My Top Bound is " +top_Bound);

//alert ("My left Bound is " +left_Bound);

//alert ("My Bottom Bound is " +bottom_Bound);

//alert ("My right Bound is " +right_Bound);


}  
 

}


}

This topic has been closed for replies.

1 reply

Techi_Panda
Inspiring
May 5, 2010

Hi Pank this will do your work

myDoc= app.activeDocument;

var myTotalPage = myDoc.pages;

//alert("Total Pages in current document is " +myTotalPage);


//var pageItems = myDoc.pages.allPageItems;

//alert ("All Page Items is "+ pageItems)

for (var i=0;i<myTotalPage.length;i++)

{

var totalTextFrames = myDoc.pages.textFrames;


//alert ("Total Text Frames on page are "+ totalTextFrames)


for (var t=totalTextFrames.length-1; t>=0;t--)

{

var Text_FRAME = myDoc.pages.textFrames;

//getting error here

app.selection=myDoc.pages.textFrames;

var top_Bound = Text_FRAME.geometricBounds[0];

var left_Bound = Text_FRAME.geometricBounds[1];

var bottom_Bound = Text_FRAME.geometricBounds[2];

var right_Bound = Text_FRAME.geometricBounds[3];


alert ("My Top Bound is " +top_Bound);

alert ("My left Bound is " +left_Bound);

alert ("My Bottom Bound is " +bottom_Bound);

alert ("My right Bound is " +right_Bound);


}  

}

PankChatAuthor
Inspiring
May 6, 2010

Thanks Arul.

Any Ideas you can share.

I think I am stuck in my script. All I am trying to do

is to find out the position of the textframes on each page and cases are :

1. If any of the text frame lies at the bottom (ideally at the page end) I

need to insert some text (marker) at the end of the story of text frame

with label "sections" (which is actually is my main non-floating frame).

2. If there is no text frame apart from the "sections" or frames are at

the bottom of page end insert something else at the end of story of

"sections" text frame.

well in short I need to add text at the end of the "sections" TF on each

page while looking at the positions of other (floats) frame. I am just

worried whether I did it write or should re-write my whole code:I am using

two scripts for this one which splits the story of pages (ideally

"sections" Threaded textframe) and another one is looks something like

below. I am stuck in comparing the Geometric bounds of frames with

"sections" one and I think something I've to do with my loops. Hope I make

myself clear.

Below is snippet what it looks like:

if(app.documents.count==0)

{

alert ("Please open a document for PageBreak");

}

else

{

var myDoc=app.activeDocument;

var myTotalPage = myDoc.pages.length;

alert("Total Pages in current document is " +myTotalPage);

//var pageItems = myDoc.pages.allPageItems;

//alert ("All Page Items is "+ pageItems)

for (var i=0; i<=myTotalPage-1; i++)

{

var totalTextFrames = myDoc.pages.textFrames.length;

alert ("Total Text Frames on page " +myDoc.pages.name " are "

totalTextFrames)

for (var t=0;t<=totalTextFrames-1;t++)

{

var Text_FRAME =

myDoc.pages.textFrames;

// alert ("Text Frame is "+Text_FRAME);

// Is actually

if (Text_FRAME.label!="sections")

{

alert ("Not sections")

var bottom_Bound_float =

Text_FRAME.geometricBounds[2];

var right_Bound_float =

Text_FRAME.geometricBounds[3];

// alert ("My right Bound of

Not Sections is " +right_Bound);

// alert ("My bottom Bound of

Not Sections is " +bottom_Bound);

// alert ("My Geometric bounds are "

+Text_FRAME.geometricBounds);

}

else

{

var top_Bound = Text_FRAME.geometricBounds[0];

var left_Bound = Text_FRAME.geometricBounds[1];

var bottom_Bound = Text_FRAME.geometricBounds[2];

var right_Bound = Text_FRAME.geometricBounds[3];

// var frame_id = Text_FRAME.id;

// alert ("My Geometric bounds are "

+Text_FRAME.geometricBounds);

//alert ("My Top Bound is " +top_Bound);

//alert ("My left Bound is " +left_Bound);

//alert ("My Bottom Bound is " +bottom_Bound);

alert ("My right Bound is " +right_Bound);

alert ("My Frame id is " +frame_id);

if(bottom_Bound_float==bottom_Bound && right_Bound_float==right_Bound)

{

alert("My Bottom Bound Float is "+bottom_Bound_float);

alert("My Bottom Bound sec is "+bottom_Bound);

//Insert some marker

//else some thing else

}

}

}

}

}