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

How to remove each Footnote textframes in a page using indesign javascript

Engaged ,
Oct 26, 2023 Oct 26, 2023

Hi I am trying to select and remove all footnote textframes in all pages of a document

TOPICS
How to , Scripting
569
Translate
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

Guide , Oct 27, 2023 Oct 27, 2023
app.activeDocument.stories.everyItem().footnotes.everyItem().remove();

 

(^/)  The Jedi

Translate
Community Expert ,
Oct 26, 2023 Oct 26, 2023

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

Translate
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
Engaged ,
Oct 26, 2023 Oct 26, 2023

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

Translate
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
LEGEND ,
Oct 27, 2023 Oct 27, 2023

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].

 

Translate
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 ,
Oct 29, 2023 Oct 29, 2023

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

Translate
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
LEGEND ,
Oct 29, 2023 Oct 29, 2023
LATEST

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...

 

Translate
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
LEGEND ,
Oct 27, 2023 Oct 27, 2023

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. 

 

Translate
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
Guide ,
Oct 27, 2023 Oct 27, 2023
app.activeDocument.stories.everyItem().footnotes.everyItem().remove();

 

(^/)  The Jedi

Translate
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