Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

How to get pagenumber of anchored Box

New Here ,
Feb 11, 2010 Feb 11, 2010

In javascript, how to get page number of anchored textbox.

if i gave "textframes[0].parent" means it shows an error.

Thanks

TOPICS
Scripting
1.2K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Engaged , Feb 11, 2010 Feb 11, 2010

Use below code:

if ((app.selection[0].parentTextFrames[0].parent.constructor.name) == "Character" && app.selection[0].parentTextFrames[0].parent.parent.constructor.name == "Story")

{

alert(app.selection[0].parentTextFrames[0].parent.parentTextFrames[0].parent.name)

}

Shonky

Translate
Community Expert ,
Feb 11, 2010 Feb 11, 2010

Usually, the "textframes" array of an object points to the textframes contained in that object. Therefore, if you ask something with textframes what the parent is of "textframes[0]", you will get that same object again.

In this case you are getting an error because there are (apparently) no text frames inside the anchored object.

To try out stuff like this you can use the "constructor.name" construction:

alert (app.selection[0].parent.constructor.name);

with the anchored object selected results "Character". That cannot ever be a part of a page, so you have to get up another level:

alert (app.selection[0].parent.parent.constructor.name);

will tell you it's a Story. Now that's obviously wrong, because a story can run over several pages. Looking into the Object Model, you will see a character also has a property "parentTextFrames" (described as "The text frames that contain the Character. Can return: Array of TextFrames or TextPaths."). Checking with

alert (app.selection[0].parent.parentTextFrames[0].constructor.name);

now returns the text frame of the story where the actual character -- in this case the Anchored object -- is located in.

For simple documents and scripts, you are done here: the parent of a text frame is the page. If this frame in turn could be anchored inside something else, or the anchored object could be inside a table or something like that, or the objects could be on the pasteboard or on a master page, you'll need additional checks.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 11, 2010 Feb 11, 2010

yes, displayed only "character", but not page number.Then how to get page number.

alert (app.selection[0].parentTextFrames[0].parent.constructor.name);

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Feb 11, 2010 Feb 11, 2010

Try this code,

alert (app.selection[0].parent.parentTextFrames[0].parent.name);

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Feb 11, 2010 Feb 11, 2010

Use below code:

if ((app.selection[0].parentTextFrames[0].parent.constructor.name) == "Character" && app.selection[0].parentTextFrames[0].parent.parent.constructor.name == "Story")

{

alert(app.selection[0].parentTextFrames[0].parent.parentTextFrames[0].parent.name)

}

Shonky

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Feb 11, 2010 Feb 11, 2010

Hi,


Use the attached script to find page of selected item.


Regards,

Ramkumar .P

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 11, 2010 Feb 11, 2010

Thanks, ramkumar for your reply.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 11, 2010 Feb 11, 2010
LATEST

That looks like one of Dave's...

Find Page has been discussed on the forums many times...

Here's one discussion:

http://forums.adobe.com/message/1109753#1109753

and here's an older one:

http://forums.adobe.com/message/1110815#1110815

I think most of the original discussions are gone already...

Harbs

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines