需求:正文中的脚注角标1为红色,页尾的脚注角标1为黑色。
是否有api支持,将正文中的角标和页尾处的角标设置不同的颜色
参考代码:
- Code: Select all
//找到脚注目标文字
TextSelection selection = document.findString("VMFS", false, true);
//添加脚注
TextRange textRange = selection.getAsOneRange();
Paragraph paragraph = textRange.getOwnerParagraph();
int index = paragraph.getChildObjects().indexOf(textRange);
Footnote footnote = paragraph.appendFootnote(FootnoteType.Footnote);
paragraph.getChildObjects().insert(index + 1, footnote);
//在脚注中添加一个段落
Paragraph paragraph1 = footnote.getTextBody().addParagraph();
//在脚注的段落中添加文本
textRange = paragraph1.appendText("VMware Virtual Machine File System,虚拟机文件系统。");
//设置脚注文本的格式
textRange.getCharacterFormat().setFontName("Arial");
textRange.getCharacterFormat().setFontSize(11);
textRange.getCharacterFormat().setTextColor(Color.green);
//设置脚注标示文本的格式
footnote.getMarkerCharacterFormat().setFontName("Calibri");
footnote.getMarkerCharacterFormat().setFontSize(12);
footnote.getMarkerCharacterFormat().setBold(true);
footnote.getMarkerCharacterFormat().setTextColor(Color.red);