Quantcast
Channel: Adobe Community: Message List
Viewing all articles
Browse latest Browse all 150094

Re: Check the first object within text frame if another text frame or normal text with JaveScript

$
0
0

Hi,

 

Are you considering a table placed in your textFrame with no container (your textFrame is a table.parent)?

Are you considering a spaces or empty lines in the beginnig of your textFrame?

 

You could detect objects at the beginning of a frame by checking

mTextFrame.texts[0].characters[0].pageItems.length    //    0 means false

 

However considering my two question a function could look like:

function objectSearcher (depth) {  var mFrame = app.selection[0];  if (!mFrame ||      mFrame.constructor.name != "TextFrame" )      return false;
// if depth no specified - whole textFrame is a target  if (isNaN (depth) ) depth = -1;  var      mText = mFrame.texts[0].characters.itemByRange(0,depth).texts[0],      mItems = mText.pageItems,      mTables = mText.tables,     //     in case of table is placed with no additional container      itemsCount = mItems.length,      tablesCount = mTables.length;  if (itemsCount || tablesCount) return true;  else return false;
}

mResult = objectSearcher ();

 

depth = 0 to check 1st character only

depth = null to check entire textFrame

 

Jarek


Viewing all articles
Browse latest Browse all 150094

Trending Articles