Copy link to clipboard
Copied
\My script need to be able to copy the text of a footnote. Works fine when the entire footnote is on the page -- but when the footnote spans pages the entire footnote text is copied. Is there some way to determine what part of the footnote text is one one page and what part is on the next?
Or even better -- to access the footnote text frame?
Thanks
Hi,
how about footnote.texts[0].parentTextFrames array?
If the array length is greater than 1 the footnote's text is split to more than one text frames.
See the following code snippet where I test the first footnote of a story where the text of the footnote is split to two frames.
The result says that text frame with id 247 holds 742 characters of the footnote text and text frame with id 251 holds 728 characters of the footnote text.
...// Characters of first footnote of a story:
var charactersArray = ap
Copy link to clipboard
Copied
Hi,
how about footnote.texts[0].parentTextFrames array?
If the array length is greater than 1 the footnote's text is split to more than one text frames.
See the following code snippet where I test the first footnote of a story where the text of the footnote is split to two frames.
The result says that text frame with id 247 holds 742 characters of the footnote text and text frame with id 251 holds 728 characters of the footnote text.
// Characters of first footnote of a story:
var charactersArray = app.documents[0].stories[0].footnotes[0].texts[0].characters.everyItem().getElements();
var charactersArrayLength = charactersArray.length ;
var resultArray = [];
// Loop the characters:
for( var c=0; c<charactersArrayLength; c++ )
{
var idString = charactersArray
.parentTextFrames[0].id.toString() ;
if( resultArray[ idString ] == undefined ){ resultArray[ idString ] = 1 }; // First occurence of id-number
else{ resultArray[ idString ] = resultArray[ idString ] + 1 }; // All other occurences of id-number
};
// Explore the results:
for( x in resultArray )
{
// id of text frame as string +"\t"+ number of characters of texts[0] of footnote:
$.writeln( x +"\t"+ resultArray
); };
/*
id number of characters of footnote text:
247 742
251 728
*/
Just an idea.
FWIW:
app.documents[0].stories[0].footnotes[0].texts[0].characters.everyItem().getElements().length
// Returns 1470, 742 + 728
Screenshot of the situation:
Regards,
Uwe
Copy link to clipboard
Copied
Can you show how you are currently selecting and copying the footnote text? "footnotes
Copy link to clipboard
Copied
Current code (using parentTextFrames)
varselText=fn.characters.itemByRange(fn.characters[0], fn.characters[-1]);
try{
selText.duplicate(LocationOptions.AT_END, tf.texts[0]);
} catch(e) { alert(e);}
break;
case 0: // spans
var start=fn.lines[0].characters[0];
var lines=fn.lines.everyItem().getElements();
for(vari=0; i<lines.length-1; i++) {
if(lines[i].parentTextFrames[0] !==lines[i+1].parentTextFrames[0]) { //we have a split footnote here
varend=lines[i].characters[-1];
break;
}
}
var selText=fn.characters.itemByRange(start, end);
selText.duplicate(LocationOptions.AT_END, tf);
break;
I still need to add the code to get the second part of the footnote
Copy link to clipboard
Copied
Ok. We could reduce the number of steps to loop through in my code if we go for lines instead of characters. 🙂
Back to your code:
What I do not understand after looking at your code:
Do you want to duplicate the text of a split footnote to a different text frame?
If not, simply duplicate texts[0] of a footnote after the end of the parent story of the text frame that is stored in variable tf.
Oh. And before duplicating check if a paragraph character is the last character in the parent story of tf.
Hm. If I'm wrong I like to see some screenshots perhaps.
Regards,
Uwe
Copy link to clipboard
Copied
The client book has two stories per page, both with footnotes.
He wants all of the footnotes at the bottom of the page instead of the bottom of each story text frame...top frame's footnotes then bottom frames's footnotes
(I'd originally thought to change the text frame footnotes to fillColor=page... but ID recomposed the page when I do that changing the layout...)