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

Get the current page content

Participant ,
Sep 22, 2022 Sep 22, 2022

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 );

-Monisha
TOPICS
How to , Scripting

Views

228

Translate

Translate

Report

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

Community Expert , Sep 22, 2022 Sep 22, 2022

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

...

Votes

Translate

Translate
Community Expert ,
Sep 22, 2022 Sep 22, 2022

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.

Votes

Translate

Translate

Report

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
Community Expert ,
Sep 22, 2022 Sep 22, 2022

Copy link to clipboard

Copied

NOTE: Edited my last reply.

 

Regards,
Uwe Laubender
( Adobe Community Expert )

Votes

Translate

Translate

Report

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
Participant ,
Sep 22, 2022 Sep 22, 2022

Copy link to clipboard

Copied

LATEST

Hi @Laubender 

 

Please accept my apologies, I was looking for the text frame contents of the active page.

 

-Monisha

Votes

Translate

Translate

Report

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
Community Expert ,
Sep 22, 2022 Sep 22, 2022

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 )

Votes

Translate

Translate

Report

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