I search how with Aspose.Words 2.4.2 for Java i can modify Font attributes of a note (Footnote or Endnote).
I have tried with the Font object available from the getter method on the Footnote object returned by the DocumentBuilder.insertNote(…) method but with this object reference the Font modified if the Font of the “index” character not the Font of note’s text itself.
For example in the sample attached i want tho modify the font the text “ENDNOTE_A” not the font of the character “ii”
Hi
Thanks for your inquiry. You can change font of all runs inside footnote. Please try using the following code:
//Open the document
Document doc = new Document("C:\\Temp\\sample.doc");
//Get collection of footnotes
NodeCollection nodes = doc.getChildNodes(NodeType.FOOTNOTE, true);
//Loop through all footnotes and change font of footnote text
for (int i = 0; i < nodes.getCount(); i++)
{
Footnote note = (Footnote)nodes.get(i);
//Get collection of runs
NodeCollection runs = note.getChildNodes(NodeType.RUN, true);
//Change font of each run
for (int j = 0; j < runs.getCount(); j++)
{
//Make text bold
((Run)runs.get(j)).getFont().setBold(true);
}
}
//Save output document
doc.save("C:\\Temp\\out.doc");
I have remarked a strange behavior but i don’t known if it come from Aspose API or MS Word itself :
When i put several Endnotes or Footnotes with the same text value, the font formatting (using your code sample) is only applied on the last (see the attached sample with the foontnote with the text “FOOTNOTE_A” or the endnote with the text “ENDNOTE_A”).
Hi
Thanks for your inquiry. When I run my code with your document all footnotes and endnotes have formatting (all are bold).
Also we have released the new version of Aspose.Words for java. https://releases.aspose.com/words/net
I used this version for testing.
Best regards,