Skip to main content
SuzzyFlamingo
Inspiring
August 4, 2025
Answered

Custom footnote separator - again

  • August 4, 2025
  • 2 replies
  • 452 views

I asked about this a while back and someone said it could be done by scripting, but I could not write a script if my life depended on it, and while i do have a friend who has done this, his script is hanging and also costs money, which I am short on now:

The challenge:

Replacing Adobe's boring FN separator ( a line) with a graphic object or a formatted text like "These are my footnotes". Anyone want to take a shot at it?

All I can contribute is that I see the ones who are selling the solution say to create a textbox and give it a name in the layer panel (I guess to tell the script what to use for the custom divider).

I asked ChatGPT, and its solution doesn't work.

Any ideas?

Thank you, and have a good day!
Susan Flamingo

 

 

Correct answer Anantha Prabu G
var doc = app.activeDocument;

// Step 1: Turn off the rule line above footnotes
doc.footnoteOptions.ruleOn = false;

// Step 2: Create paragraph style if it doesn't exist
var styleName = "Footnote Separator";
var sepStyle;

try {
    sepStyle = doc.paragraphStyles.itemByName(styleName);
    sepStyle.name;
} catch (e) {
    sepStyle = doc.paragraphStyles.add({ name: styleName });
    sepStyle.justification = Justification.LEFT_ALIGN;
    sepStyle.pointSize = 10;
    sepStyle.spaceBefore = 2;
    sepStyle.spaceAfter = 2;
}

// Step 3: Track which pages already got a separator
var pagesWithSeparators = {};

// Step 4: Loop through all stories and all footnotes
for (var s = 0; s < doc.stories.length; s++) {
    var story = doc.stories[s];
    var footnotes = story.footnotes;

    for (var f = 0; f < footnotes.length; f++) {
        var fn = footnotes[f];

        try {
            var fnText = fn.texts[0]; // The actual content of the footnote
            var fnPage = fnText.parentTextFrames[0].parentPage;

            if (fnPage && !pagesWithSeparators[fnPage.name]) {
                // Insert separator at the top of the footnote content
                var firstPara = fnText.paragraphs[0];
                firstPara.insertionPoints[0].contents = "---- This is my FN separator ----\r";
                firstPara.appliedParagraphStyle = sepStyle;

                pagesWithSeparators[fnPage.name] = true; // Mark page as handled
            }

        } catch (e) {
            $.writeln("Error handling footnote " + f + ": " + e);
        }
    }
}

alert("Footnote separators inserted on every page where footnotes appear.");

2 replies

brian_p_dts
Community Expert
Community Expert
August 4, 2025

Copy your graphic object or stylized frame to the clipboard with the anchored object settings you want, then use Grep. Find is ~F, change is ~c

m1b
Community Expert
Community Expert
August 5, 2025

@brian_p_dts, very nice! But sadly won't help in this case I don't think because ~F is the footnote reference, not the footnote itself.

- Mark

Anantha Prabu G
Legend
August 4, 2025

Hi @SuzzyFlamingo 
Could you please post the screenshot?

Design smarter, faster, and bolder with InDesign scripting.
SuzzyFlamingo
Inspiring
August 4, 2025

Here is what Adobe FN looks like by default:

And we want to automate looking like this:

Anantha Prabu G
Anantha Prabu GCorrect answer
Legend
August 4, 2025
var doc = app.activeDocument;

// Step 1: Turn off the rule line above footnotes
doc.footnoteOptions.ruleOn = false;

// Step 2: Create paragraph style if it doesn't exist
var styleName = "Footnote Separator";
var sepStyle;

try {
    sepStyle = doc.paragraphStyles.itemByName(styleName);
    sepStyle.name;
} catch (e) {
    sepStyle = doc.paragraphStyles.add({ name: styleName });
    sepStyle.justification = Justification.LEFT_ALIGN;
    sepStyle.pointSize = 10;
    sepStyle.spaceBefore = 2;
    sepStyle.spaceAfter = 2;
}

// Step 3: Track which pages already got a separator
var pagesWithSeparators = {};

// Step 4: Loop through all stories and all footnotes
for (var s = 0; s < doc.stories.length; s++) {
    var story = doc.stories[s];
    var footnotes = story.footnotes;

    for (var f = 0; f < footnotes.length; f++) {
        var fn = footnotes[f];

        try {
            var fnText = fn.texts[0]; // The actual content of the footnote
            var fnPage = fnText.parentTextFrames[0].parentPage;

            if (fnPage && !pagesWithSeparators[fnPage.name]) {
                // Insert separator at the top of the footnote content
                var firstPara = fnText.paragraphs[0];
                firstPara.insertionPoints[0].contents = "---- This is my FN separator ----\r";
                firstPara.appliedParagraphStyle = sepStyle;

                pagesWithSeparators[fnPage.name] = true; // Mark page as handled
            }

        } catch (e) {
            $.writeln("Error handling footnote " + f + ": " + e);
        }
    }
}

alert("Footnote separators inserted on every page where footnotes appear.");
Design smarter, faster, and bolder with InDesign scripting.