Copy link to clipboard
Copied
Hi I am trying to select and remove all footnote textframes in all pages of a document
app.activeDocument.stories.everyItem().footnotes.everyItem().remove();
(^/) The Jedi
Copy link to clipboard
Copied
Every textframe has a footnotes property. You can iterate on the textframes collection and check the footnotes length, if it is greater that 0 you can delete the textframe.
Something like
if(tf.footnotes.length) //delete the textframe
-Manan
Copy link to clipboard
Copied
I tried it but the footnotes length
var doc = app.activeDocument;
var pagess = doc.pages;
for(var p=0; p<pagess.length; p++){
var pgTxtFrames = pagess[40].textFrames;
for(var t=0; t<pgTxtFrames.length; t++){
// pgTxtFrames[t].remove();
if(pgTxtFrames[t].footnotes.length >0){
for(var f=0; f<pgTxtFrames[t].footnotes.length; f++){
pgTxtFrames[t].footnotes[0].parentTextFrames[0].remove();
}
}
}
}
was Zero but footnotes were present in each page
Copy link to clipboard
Copied
This line is your problem:
var pgTxtFrames = pagess[40].textFrames;
You are referring to a 40th page all the time - it should be "p" instead - [p].
Copy link to clipboard
Copied
HI @Karthik SG,
You don't need to run a loop for every footnote in a frame. If the footnote count is greater that 0 then delete it. Adding the fix listed by @Robert at ID-Tasker the following should work
var doc = app.activeDocument;
var pagess = doc.pages;
for(var p=0; p < pagess.length; p++){
var pgTxtFrames = pagess[p].textFrames;
for(var t=0; t < pgTxtFrames.length; t++){
if(pgTxtFrames[t].footnotes.length > 0)
pgTxtFrames[t].remove()
}
}
-Manan
Copy link to clipboard
Copied
I'm pretty sure it's not what OP wants - @FRIdNGE already gave the solution - https://community.adobe.com/t5/indesign-discussions/how-to-remove-each-footnote-textframes-in-a-page...
Copy link to clipboard
Copied
You can't delete footnote's TextFrame - footnote shares TextFrame of the text where the reference is - you need to delete reference in the text.
Copy link to clipboard
Copied
app.activeDocument.stories.everyItem().footnotes.everyItem().remove();
(^/) The Jedi