Copy link to clipboard
Copied
Hi,
Although I have fetched the content of the InDesign document, I need the current page content. Could you please assist me with this?
To get the InDesign document's content, I used this.
var myDoc = app.activeDocument;
var myText= "";
for (var i = 0; myDoc.stories.length > i; i++)
myText += myDoc.textFrames[i].texts[0].contents;
alert("Document contains " + myText );
On: The contents of a page is stored in the array page.allPageItems.
The same with a spread. spread.allPageItems.
If you want to filter all text frames of a given page, you could loop the allPageItems array of a given page.
Then ask every item if it is a text frame after you "resolved" it with getElements() like that:
if( myActivePage.allPageItems[i].getElements()[0].constructor.name == "TextFrame" )
{
// do something.
};
There are other methods as well. You could loop the textContainers array
...Copy link to clipboard
Copied
Hi @MonishaRajendran ,
please specify what you mean by "current page".
Do you mean the active page on the active spread?
Explore:
var activeSpread = myDoc.layoutWindows[0].activeSpread;
var activePage = myDoc.layoutWindows[0].activePage;
var pageOffset = activePage.documentOffset;
var pageName = activePage.name;
Regards,
Uwe Laubender
( Adobe Community Expert )
EDITED CODE ABOVE: Changed app to myDoc.
Copy link to clipboard
Copied
NOTE: Edited my last reply.
Regards,
Uwe Laubender
( Adobe Community Expert )
Copy link to clipboard
Copied
Hi @Laubender
Please accept my apologies, I was looking for the text frame contents of the active page.
Copy link to clipboard
Copied
On: The contents of a page is stored in the array page.allPageItems.
The same with a spread. spread.allPageItems.
If you want to filter all text frames of a given page, you could loop the allPageItems array of a given page.
Then ask every item if it is a text frame after you "resolved" it with getElements() like that:
if( myActivePage.allPageItems[i].getElements()[0].constructor.name == "TextFrame" )
{
// do something.
};
There are other methods as well. You could loop the textContainers array of all given stories in the document and look for the value of parentPage. If this is identical to your active page store it to an array and when done with all textContainers of all stories loop the result array to do something with its contents.
Regards,
Uwe Laubender
( Adobe Community Expert )