Dirk Ulrich wrote:
But this way, the numbering seems not to be continued in the scetions/subsections.
In your pdf the numbering is:
1. chapter 1
1. Section 1 (BTW: without indentation)

I have adapted the example. Have a look at the attachment.
Now there IS an indentation; and the lines added to provide
this indentation don't introduce any now functionality.
In my previous examples, I provided the indentation for
the subsections in the same way.
Tsssk...
Bruno
package test;

import java.io.FileOutputStream;
import java.io.IOException;

import com.lowagie.text.Chapter;
import com.lowagie.text.Document;
import com.lowagie.text.DocumentException;
import com.lowagie.text.Paragraph;
import com.lowagie.text.Section;
import com.lowagie.text.pdf.PdfWriter;

public class Dirk {
        public static void main(String[] args) {
                Document document = new Document();
                try {
                        PdfWriter.getInstance(document, new 
FileOutputStream("dirk.pdf"));
                        document.open();
                        Chapter chapter1 = new Chapter("Chapter 1", 1);
                        chapter1.setNumberDepth(0);
                        Paragraph sectionTitle = new Paragraph("Section");
                        sectionTitle.setIndentationLeft(20);
                        Section section1 = chapter1.addSection(20, 
sectionTitle);
                        section1.add(new Paragraph("blah blah blah"));
                        section1.setNumberDepth(2);
                        Paragraph title1 = new Paragraph("subsection 1");
                        title1.setIndentationLeft(20);
                        Section subsection1 = section1.addSection(20, title1);
                        subsection1.add(new Paragraph("blah blah blah"));
                        Paragraph title2 = new Paragraph("subsection 2");
                        title2.setIndentationLeft(20);
                        Section subsection2 = section1.addSection(20, title2);
                        subsection2.add(new Paragraph("blah blah blah"));
                        Section section2 = chapter1.addSection(20, "Section");
                        section2.add(new Paragraph("blah blah blah"));
                        section2.setNumberDepth(2);
                        document.add(chapter1);
                        Chapter chapter2 = new Chapter("Chapter 2", 2);
                        chapter2.setTriggerNewPage(false);
                        document.add(chapter2);
                } catch (IOException e) {
                        e.printStackTrace();
                } catch (DocumentException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                }
                document.close();
        }
}

Attachment: dirk.pdf
Description: application/octetstream

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://itext.ugent.be/itext-in-action/

Reply via email to