Paragraph blahblah = new Paragraph("blah blah blah blah blah blah blaah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah");
Paragraph blahblahblah = new Paragraph("blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blaah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah");
// this loop will create 7 chapters
for (int i = 1; i < 8; i++) {
Paragraph cTitle = new Paragraph("This is chapter " + i, chapterFont);
Chapter chapter = new Chapter(cTitle, i);
// in chapter 4 we change the alignment to ALIGN_JUSTIFIED
if (i == 4) {
blahblahblah.setAlignment(LwgElement.ALIGN_JUSTIFIED);
blahblah.setAlignment(LwgElement.ALIGN_JUSTIFIED);
chapter.add(blahblah);
}
// in chapter 5, the alignment is changed again
if (i == 5) {
blahblahblah.setAlignment(LwgElement.ALIGN_CENTER);
blahblah.setAlignment(LwgElement.ALIGN_RIGHT);
chapter.add(blahblah);
}
// the alignment is changed to ALIGN_JUSTIFIED again
if (i == 6) {
blahblahblah.setAlignment(LwgElement.ALIGN_JUSTIFIED);
blahblah.setAlignment(LwgElement.ALIGN_JUSTIFIED);
}
// in every chapter 3 sections will be added
for (int j = 1; j < 4; j++) {
Paragraph sTitle = new Paragraph("This is section " + j + " in chapter " + i, sectionFont);
Section section = chapter.addSection(sTitle, 1);
// for chapters > 2, the outine isn't open by default
if (i > 2) section.setBookmarkOpen(false);
// in all chapters except the 1st one, some extra text is added to section 3
if (j == 3 && i > 1) {
section.setIndentationLeft(72);