Hello,
Thank you for your inquiry.
Please use the following code to implement that only Heading1 is bold.
- Code: Select all
paragraph.appendTOC(1,3);
ParagraphStyle tocStyle = (ParagraphStyle) Style.createBuiltinStyle(BuiltinStyle.Toc_1, document);
tocStyle.getCharacterFormat().setBold(false);
document.getStyles().add(tocStyle);
for (int j = 0; j < section.getChildObjects().getCount(); j++) {
DocumentObject cObj = section.getChildObjects().get(j);
if (cObj instanceof Paragraph) {
Paragraph para = (Paragraph) ((cObj instanceof Paragraph) ? cObj : null);
if (para.getStyleName().equals("TOC2") || para.getStyleName().equals("TOC3")) {
para.applyStyle(tocStyle.getName());
}
}
}
document.updateTableOfContents();
Also, do you mean not to display page numbers when you mention 'there are spaces after each line in the table of contents'? If so, please use the following code. If not, please provide a more detailed explanation. Thank you in advance.
- Code: Select all
TableOfContent content = paragraph.appendTOC(1,3);
content.setRightAlignPageNumbers(false);
Sincerely,
Annika
E-iceblue support team