I need to hide the number of sections and chapters within the files that I generate with iTextSharp (within the content of the file, I do not care about bookmarks), for example I would need to change the actual result generated this way:
This is Chapter Title 1
1.1. This in section Title 1
by the following:
This is Chapter Title 1
This in section Title 1
I tried the following code, overriding the method OnSection:
public override void OnSection(PdfWriter writer, Document document, float paragraphPosition, int depth, Paragraph title)
{title.RemoveAt(0);
base.OnSection(writer, document, paragraphPosition, depth, title);
}
But I did not get any results, could anyone help? Thank you very much, Ariel
A chapter number has to be created using a Paragraph as title and an int as chapter number. The chapter number is shown by default. If you don't want to see the chapter number, you have to set the numberdepth
to 0.
The same counts for section.
Sample:
Chapter chapter = new Chapter("ChapterTitle", 0);
chapter.NumberDepth = 0;
Section section = chapter.AddSection("Title", 0);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With