Skip to main content
karthikS
Inspiring
October 10, 2022
Answered

Get content from Anchored text frame

  • October 10, 2022
  • 2 replies
  • 542 views

Hi friends,

Please help on this. 

How to get content in the Anchored text-frame from linked footnote element.

My Process: first i need to select footnote element and catch with Anchor text-frame contents.

 

 

Kindly advice on this.

 

Thanks in Advance,

Karthik S

This topic has been closed for replies.
Correct answer Laubender

Hi @karthikS ,

if you get the footnote text you can access all text frames in that text and then get the contents or the formatted text inside the anchored text frame. In dummy code, variable myFootnote below should contain a footnote object, for the first text frame in the footnote text:

myFootnote.texts[0].textFrames[0].parentStory.contents

or all formatted text:

myFootnote.texts[0].textFrames[0].parentStory

 

Regards,
Uwe Laubender

( Adobe Community Expert )

 

2 replies

LaubenderCommunity ExpertCorrect answer
Community Expert
October 10, 2022

Hi @karthikS ,

if you get the footnote text you can access all text frames in that text and then get the contents or the formatted text inside the anchored text frame. In dummy code, variable myFootnote below should contain a footnote object, for the first text frame in the footnote text:

myFootnote.texts[0].textFrames[0].parentStory.contents

or all formatted text:

myFootnote.texts[0].textFrames[0].parentStory

 

Regards,
Uwe Laubender

( Adobe Community Expert )

 

karthikS
karthikSAuthor
Inspiring
October 10, 2022

Hi Uwe,

Thanks lot! this is working fine.

m1b
Community Expert
Community Expert
October 10, 2022

Hi @karthikS, in cases like this, it is always helpful to attach a sample indesign document. It can be just one page with the footnote and anchored text frame. It will make it easier and quicker for people to help. - Mark

karthikS
karthikSAuthor
Inspiring
October 10, 2022

Hi Mark,

Thanks! i have attached the indd file for your reference. Kindly check and advice on this.

m1b
Community Expert
Community Expert
October 10, 2022

Hi @karthikS, here is my approach. @Laubender your way is very simple. Maybe I am overthinking it?

- Mark

 

var doc = app.activeDocument;

// find all anchors
app.findGrepPreferences = NothingEnum.NOTHING;
app.findGrepPreferences.findWhat = '~a';
var found = doc.findGrep();

// discard any anchors without the xml tag 'footnote'
for (var i = found.length - 1; i >= 0; i--)
    if (found[i].associatedXMLElements[0].markupTag.name != 'footnote')
        found.splice(i, 1);

// get the anchored text frames contents
var anchoredContents = [];
for (var i = 0; i < found.length; i++)
    anchoredContents.push(found[i].textFrames[0].contents);

// now you have each contents
alert(anchoredContents[0]);
alert(anchoredContents[1]);