Openpdf: How to remove dot after chapter/section number?

Created on 31 Mar 2020  路  2Comments  路  Source: LibrePDF/OpenPDF

ChapterAutoNumber make chapter header with dot after its number (example: 1. Chapter name).
I need to remove ending dot (example: 1 Chapter name).
How can i do it?

The same problem with sections.

help wanted question

Most helpful comment

I'm use ChapterAutoNumber like this:

ChapterAutoNumber chapter = new ChapterAutoNumber(new Paragraph(chapterTitle));

for (lib.text.model.element.Element element : rubric) {
    chapter.add(new Paragraph(element.getText()));
}

// Sections
for (Rubric subRubric: rubric.getSubrubrics()) {
  Paragraph sectTitle = new Paragraph(subRubric.getTitle());

  Section section = chapter.addSection(sectTitle);
  section.setIndentationLeft(settings.indentSize);

  for (lib.text.model.element.Element element : subRubric) {
      chapter.add(new Paragraph(element.getText()));
  }
}

pdfDoc.add(chapter);

Yes. public static final int NUMBERSTYLE_DOTTED_WITHOUT_FINAL_DOT = 1; is what i need.
chapter.setNumberStyle(NUMBERSTYLE_DOTTED_WITHOUT_FINAL_DOT); works fine.

Thanks.

All 2 comments

Can you add how you use ChapterAutoNumber?
In Section you can find
public static final int NUMBERSTYLE_DOTTED = 0; and
public static final int NUMBERSTYLE_DOTTED_WITHOUT_FINAL_DOT = 1;
maybe this could help you?

I'm use ChapterAutoNumber like this:

ChapterAutoNumber chapter = new ChapterAutoNumber(new Paragraph(chapterTitle));

for (lib.text.model.element.Element element : rubric) {
    chapter.add(new Paragraph(element.getText()));
}

// Sections
for (Rubric subRubric: rubric.getSubrubrics()) {
  Paragraph sectTitle = new Paragraph(subRubric.getTitle());

  Section section = chapter.addSection(sectTitle);
  section.setIndentationLeft(settings.indentSize);

  for (lib.text.model.element.Element element : subRubric) {
      chapter.add(new Paragraph(element.getText()));
  }
}

pdfDoc.add(chapter);

Yes. public static final int NUMBERSTYLE_DOTTED_WITHOUT_FINAL_DOT = 1; is what i need.
chapter.setNumberStyle(NUMBERSTYLE_DOTTED_WITHOUT_FINAL_DOT); works fine.

Thanks.

Was this page helpful?
0 / 5 - 0 ratings