Skip to main content
Peter Kahrel
Peter KahrelCorrect answer
Community Expert
Jul 30, 2025 7:33 PM UTC

109 lines. I downloaded yesterday.

 

//DESCRIPTION: Place a footnote in the previous note's breakline
 
(function () {
 
if (app.selection.length === 0 || app.selection[0].parent.constructor.name !== 'Footnote') {
alert ('Place the cursor in a footnote and start again.');
exit();
}
 
app.scriptPreferences.measurementUnit = MeasurementUnits.POINTS;
 
var doc = app.documents[0];
var sel = app.selection[0];
var fnotes = sel.parentTextFrames[0].footnotes.everyItem().getElements();
var break_style = checkStyle();
var footn = sel.parent;
var space = 1 * break_style.pointSize;
var index = footn.index-fnotes[0].index;
var bottom = sel.parentTextFrames[0].geometricBounds[2];
var left_to_right = sel.paragraphDirection === ParagraphDirectionOptions.LEFT_TO_RIGHT_DIRECTION;
if (index === 0) {
alert ('To move note 2 immediately after note 1, \rplace the cursor in note 2, then run the script.')
exit();
}
 
 
function checkStyle () {
var breakstyleName = doc.footnoteOptions.footnoteTextStyle.name.replace (/[\[\]]/g,'') + '_breakline';
if (!doc.paragraphStyles.item (breakstyleName).isValid) {
doc.footnoteOptions.properties = {
footnoteMinimumFirstBaselineOffset: 0,
footnoteFirstBaselineOffset: FootnoteFirstBaseline.LEADING_OFFSET,
};
var fnoteStyle = doc.footnoteOptions.footnoteTextStyle;
if (!doc.characterStyles.item (breakstyleName).isValid) {
doc.characterStyles.add ({
name: breakstyleName, 
leading: 0,
});
}
var temp = doc.paragraphStyles.add ({name: breakstyleName, basedOn: fnoteStyle});
temp.nestedLineStyles.add ({
appliedCharacterStyle: doc.characterStyles.item(breakstyleName),
lineCount: 1,
});
}
return doc.paragraphStyles.item (breakstyleName);
}
 
function get_indent () {
var previous_note = fnotes[index-1].paragraphs[0];
if (left_to_right) {
var end = previous_note.lines[-1].insertionPoints[-1].horizontalOffset;
var start = previous_note.parentTextFrames[0].geometricBounds[1];
} else {
var start = previous_note.lines[-1].insertionPoints[-1].horizontalOffset;
var end = previous_note.lines[-1].parentTextFrames[0].geometricBounds[3];
}
return (end-start) + space;
}
 
 
function note_to_inline () {
var fn_par = footn.paragraphs[0];
fn_par.applyParagraphStyle (break_style, false);
 
var diff = Math.abs (fn_par.baseline - fnotes[index-1].characters[-1].baseline);
if (diff > 0) {
fn_par.texts[0].baselineShift = diff;
}
 
if (left_to_right) {
fn_par.leftIndent = 0;
} else {
fn_par.rightIndent = 0;
}
 
if (fn_par.characters[0].contents !== SpecialCharacters.DISCRETIONARY_LINE_BREAK) {
fn_par.insertionPoints[0].contents = '\u200B'; // Discretionary line break
}
fn_par.firstLineIndent = get_indent();
}
 
 
function fitMainFrame () {
var frame = app.selection[0].parent.storyOffset.parentTextFrames[0];
var fnBottom = frame.footnotes[-1].characters[-1].baseline;
var bottomMargin = frame.parentPage.bounds[2] - frame.parentPage.marginPreferences.bottom;
var diff = bottomMargin - fnBottom;
if (Math.round (diff) !== 0) {
var gb = frame.geometricBounds;
frame.geometricBounds = [gb[0], gb[1], gb[2]+diff, + gb[3]];
}
}
 
 
note_to_inline(); // Set the selected note in the previous note's breakline
// If this is a re-run, there may be 
// more inline notes in the same cluster
if (index < fnotes.length-1) {
footn = fnotes[++index];
while (index < fnotes.length && footn.paragraphs[0].appliedParagraphStyle.name.indexOf('_breakline') > -1) {
note_to_inline();
footn = fnotes[++index];
}
}
fitMainFrame ();
 
}());

This is very strange. There are several differences, the one you downloaded is an older version. From what I can see the version on the server is correct -- as I mentioned, I downloaded it and it's the correct one. I'll ask CreativePro to look into it.

 

Meanwhile, the correct ersion is attached here. Just change the .txt file type to .jsx -- and change line 5 🙂

 

7 replies

Peter Kahrel
Community Expert
Community Expert
Jul 29, 2025 7:34 PM UTC

The web page says that the line you're after is line 5. These are the first few lines of the script:

//DESCRIPTION: Place a footnote in the previous note's breakline

(function () {
	
  var number_of_ems = 2;

 

Translate
Inspiring
Jul 30, 2025 1:22 PM UTC

Do I have to add that line in because it isn't on line 5. Mine looks like below:

//DESCRIPTION: Place a footnote in the previous note's breakline
 
(function () {
 
if (app.selection.length === 0 || app.selection[0].parent.constructor.name !== 'Footnote') {
alert ('Place the cursor in a footnote and start again.');
exit();
}
Translate
Peter Kahrel
Community Expert
Community Expert
Jul 30, 2025 2:28 PM UTC

How bizarre. I downloaded the script just now and the line is there. When did you download it? How many lines does the script have?

Translate