Apply character style to the footnote reference depending on the paragraph style applied to the note

New Here ,
Oct 28, 2020 Oct 28, 2020

Copy link to clipboard

Copied

Hello,

I have two paragraph styles for footnotes and two character styles for footnote references.
I need to write a script that detects the paragraph style applied to the footnote and, depending on that, apply a certain character style to the footnote reference.
If the footnote have applied the paragraph style no. 1, then on its reference must be applied the character style no. 1, and same for no. 2.
I don't know how to access the footnote reference and apply the needed character style.

Thanks in advance for your help.

TOPICS
Scripting

Views

117

Likes

translate

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

Adobe Community Professional , Oct 28, 2020 Oct 28, 2020
Hi aditz_a, every footnote object has a texts property. To get the applied paragraph style of a given footnote text ( the first paragraph ) could work like that:     // Example with some footnotes in a text selection: var textSelection = app.selection[0]; var footnotesArray = textSelection.footnotes.everyItem().getElements(); for( var n=0; n<footnotesArray.length; n++ ) { var currentFootnote = footnotesArray[n]; var parent = currentFootnote.storyOffset.parent; var index = currentFootnote.sto...

Likes

translate

Translate

Translate
Adobe Community Professional ,
Oct 28, 2020 Oct 28, 2020

Copy link to clipboard

Copied

Hi aditz_a,

every footnote object has a texts property.

To get the applied paragraph style of a given footnote text ( the first paragraph ) could work like that:

 

 

// Example with some footnotes in a text selection:
var textSelection = app.selection[0];
var footnotesArray = textSelection.footnotes.everyItem().getElements();

for( var n=0; n<footnotesArray.length; n++ )
{
	var currentFootnote = footnotesArray[n];
	var parent = currentFootnote.storyOffset.parent;
	var index = currentFootnote.storyOffset.index;
	
	var footnoteSpecialChar = parent.characters[ index ];
	
	var footnoteText = currentFootnote.texts;
	var appliedParaStyle = footnoteText.insertionPoints[0].appliedParagraphStyle;
	
	/*
		Now test the appliedParaStyle and apply the right character style to:
		footnoteSpecialChar
	*/
	
};

 

 

All available properties for footnotes are listed e.g. here:

https://www.indesignjs.de/extendscriptAPI/indesign-latest/#Footnote.html

 

Regards,
Uwe Laubender

( ACP )

 

// EDITED CODE

Likes

translate

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
New Here ,
Oct 29, 2020 Oct 29, 2020

Copy link to clipboard

Copied

Thank you, very very much!

It worked like a charm. 🙂

Likes

translate

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