Skip to main content
Known Participant
January 16, 2009
Answered

Get page no from insertionpoint.

  • January 16, 2009
  • 4 replies
  • 977 views
Hi all,

I want to find (return) the page with the given insertion point. The insertion point may be present in a textframe or in a group or in a group within a group, etc..,

Is it possible to get the return type of the object?

thanks,
Hemi
This topic has been closed for replies.
Correct answer rob day

Here’s what I have that works in my code, starting from an insertionPoint that is defined by a story.findText() call:

 

 

var this_insertionPoint = finds[0].insertionPoints[-1];
var this_absolute_page = this_insertionPoint.parentTextFrames[0].parentPage.documentOffset;
var this_page = doc.pages[this_absolute_page];
var this_side = this_page.side;

 


.documentOffset starts at 0, so I think you’ll need +1

 

 

 

 

var searchRes = styleSearch("Hello World")
if (searchRes.length > 0) {
    var ip = searchRes[0].insertionPoints[-1].parentTextFrames[0].parentPage
	alert("Last Insertion Point of first found text is on absolute page " + (ip.documentOffset+1) + "\rPage is on: " + ip.side.toString() + " Side of Spread" )
} 

/**
* Find Text 
* @ param Text to search for 
* @ return search results as an array 
*/
function styleSearch(f){
    app.findTextPreferences = app.changeTextPreferences = app.findChangeTextOptions = null;
    app.findTextPreferences.findWhat = f;
    return app.activeDocument.findText()
}

 

 

 

 

 

4 replies

Community Expert
January 2, 2023

Hi @Chris Noessel_731 ,

note that the original thread is from 2009 and the question revolved around InDesign CS3 version 5.

To get the page of a given pageItem has changed with InDesign CS5 version 7. And stays with us until now.

Property parentPage was introduced with InDesign CS5. Its value will become null if the object is considered outside of the page on the pasteBoard.

 

Regards,
Uwe Laubender
( Adobe Community Expert )

Inspiring
January 16, 2009
see: http://www.adobeforums.com/webx/.59b77ee3/6

For the most recent thread on this topic.

Dave
Participating Frequently
January 1, 2023

This link no longer works, and I’m having a devil of a time trying to find a relevant article using the search features. If you have it handy, can you relink?

Participating Frequently
January 1, 2023

Though poking around the object model, I think I have it!

 

this_insertionPoint.parentTextFrames[0].parentPage.side, which is read-only, and results in one of the following…
  • PageSideOptions.LEFT_HAND
  • PageSideOptions.RIGHT_HAND
  • PageSideOptions.SINGLE_SIDED
Known Participant
January 16, 2009
Hi Peter,

Version CS3. Either javascript or vb.net
Peter Kahrel
Community Expert
Community Expert
January 16, 2009
There have been several examples of this in this forum recently. You'll find them using the forum search or Google. Also, please state your InDesign version and what script language you use.

Peter