Bruno Lowagie wrote:
> On my bike on the way home from work, it occurred
> to me that I have fixed an indentation problem
> concerning tables recently. That may be a good hint
> to adapt the example so that it reproduces the problem.
I followed my own advice, added a table to the simple
code sample (see attachment), and was able to reproduce
the problem.
Using this small code sample, it was easy for me to fix
the problem. The solution is in the CVS (class PdfDocument).
More and more people are using iText, so more and more
functionality that was never used before (because it's rather
exotic) is now being put to the test.
In the last few weeks several bugs that have been present
in iText for ages, but remained unnoticed all that time,
were reported using similar small code samples.
As I have said before: these code samples are crucial in
the debugging process. If I can't reproduce a problem,
I can't fix it. Saying 'it doesn't work', or sending code
that can't be run as a standalone app, is of no use.
It only leads to confusion and frustrations on both sides.
Only well documented problems make a chance of being fixed.
br,
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.PdfPTable;
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");
PdfPTable table = new PdfPTable(2);
table.addCell("1");
table.addCell("2");
subsection1.add(table);
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();
}
}
-------------------------------------------------------------------------
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/