Copy link to clipboard
Copied
Hi,
For each text frame, I used to get the page number. Presently, InDesign documents with 6 text frames will display page numbers for just four of the text frames, not all of the text frames. Here is the script I used to do it.
var MSIDvalue = [];
var myXMLFile;
var getsearchtextpageNUmber = [];
var getxmlvalues =[];
var getCDATAValue = [];
var InddFrameValue = [];
var getPageNumberValue = [];
var getsearchtextpageNUmber ;
var getsearchtextpageNUmber =[];
var myGroup = app.activeDocument;
var allPageItemsOfGroup = myGroup.allPageItems;
for(var n=0;n<allPageItemsOfGroup.length;n++){
var myObject = allPageItemsOfGroup[n].getElements()[0];
if(myObject.constructor.name === "TextFrame" )
var myFrame = app.activeDocument.textFrames;
var mySelectedXMLItem = myFrame[n].associatedXMLElement;
if(mySelectedXMLItem != null && mySelectedXMLItem.markupTag.name != null)
var node_TBGUID = myFrame[n].associatedXMLElement.xmlAttributes.itemByName("MSID").value;
MSIDvalue.push(node_TBGUID);
var myFrames = myFrame[n].texts[0].contents;
app.findGrepPreferences=NothingEnum.NOTHING; //to reset the Grep search
app.findGrepPreferences.findWhat = myFrames; //the word(s) you are searching
var find = app.activeDocument.findGrep (true); //execute search
var a = app.activeDocument.findGrep( true )
for (var r = 0; r < a.length; r++)
getsearchtextpageNUmber.push(a [r].parentTextFrames[0].parentPage.name) ; //output
}
You need to debug and see that the array "a" has 6 elements or not. This array is populated with the findGrep result so check if the result should bring in all the frames as you expect. Also, see the following two consecutive statements, doing the same thing then why do you need both
var find = app.activeDocument.findGrep(true); //execute search
var a = app.activeDocument.findGrep(true)
In addition as I mentioned in another thread, you need to check for the possibility of the pageitem not being
Hi @Manan Joshi
I have modified the script and now it's working fine. Hereby I have attached the script which I have used.
var doc = app.activeDocument;
var gettextframe = app.activeDocument.textFrames;
for(var q=0;q<gettextframe.length;q++)
getPageNumberValue.push(doc.textFrames[q].parentPage.name);
Copy link to clipboard
Copied
You need to debug and see that the array "a" has 6 elements or not. This array is populated with the findGrep result so check if the result should bring in all the frames as you expect. Also, see the following two consecutive statements, doing the same thing then why do you need both
var find = app.activeDocument.findGrep(true); //execute search
var a = app.activeDocument.findGrep(true)
In addition as I mentioned in another thread, you need to check for the possibility of the pageitem not being on a page at all.
-Manan
Copy link to clipboard
Copied
Hi @Manan Joshi
I have modified the script and now it's working fine. Hereby I have attached the script which I have used.
var doc = app.activeDocument;
var gettextframe = app.activeDocument.textFrames;
for(var q=0;q<gettextframe.length;q++)
getPageNumberValue.push(doc.textFrames[q].parentPage.name);
Copy link to clipboard
Copied
The name of your variable is a bit "misleading" - .parentPage.name returns "name" of the page - not its index in the document.
Copy link to clipboard
Copied
Are you sure your code is working correctly??? It looks a bit strange... You are trying to process all TextFrames in the group - but then you are referencing to ALL TextFrames in the document???