On Friday 09 September 2005 16:31, Karsten Klein wrote: > This piece of code generates a rtf document. However with many additions > I don't want to have: > 1) a section page break after the chapter (thus the first page is empty > except for the chapter) > 2) two newlines after the section header > > Is there I way to remove both side-effects? Problem number 1 is caused by writing the Chapter to the document and only then creating the Section and adding it to the document. The correct method is to create the Chapter, add a Section, add the Paragraph to the Section and then add the Chapter to the document. The Section and Paragraph are automatically added.
Paragraph cTitle = new Paragraph("Chapter 1 - What the fuzz?");
Chapter chapter = new Chapter(cTitle, 1);
chapter.setNumberDepth(0);
// create a section
Paragraph p = new Paragraph("I can see the stars");
Section section = chapter.addSection(p, 1);
section.setNumberDepth(1);
// some text phrase
String text = "This is the section text";
Paragraph paragraph = new Paragraph(text);
section.add(paragraph);
// add chapter to document
doc.add(chapter);
Problem number 2 has been fixed in the latest release.
If the Chapter is the first thing you add to the document then you will get an
empty first page. A fix for this is in the CVS and will be in the next
release.
Greetings,
Mark
--
The difference between the right word and the almost right word is the
difference between lightning and the lightning bug.
-- Mark Twain
My GPG public key is available at:
http://www.edu.uni-klu.ac.at/~mhall/data/security/MarkHall.asc
pgpTXLkN16NXJ.pgp
Description: PGP signature
