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

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

Engaged ,
Oct 26, 2023 Oct 26, 2023

Copy link to clipboard

Copied

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

TOPICS
How to , Scripting

Views

263

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

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

 

(^/)  The Jedi

Votes

Translate

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

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

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

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

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

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

 

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

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

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

Copy link to clipboard

Copied

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

 

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

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. 

 

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

Copy link to clipboard

Copied

app.activeDocument.stories.everyItem().footnotes.everyItem().remove();

 

(^/)  The Jedi

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