Hello
I am new to iText
and find it is a great product. Thanks to all those helping to develop
it!
I have come across
a problem, which might turn out to be a bug (in my code or in iTexts). Consider
the following code:
final Document doc = new
Document(PageSize.A4);
final OutputStream stream1 = new FileOutputStream("C:/Temp/Test1.pdf");
final PdfWriter writer1 = PdfWriter.getInstance(doc, stream1);
final ByteArrayOutputStream stream2 = new ByteArrayOutputStream();
final PdfWriter writer2 = PdfWriter.getInstance(doc, stream2);
doc.open();
doc.add(new Paragraph("Hallo"));
final MultiColumnText cols = new MultiColumnText();
cols.addRegularColumns(doc.left(), doc.right(), 10f, 3);
for (int i = 0; i < 100; i++) {
cols.addElement(new Paragraph("Hallo"));
}
doc.add(cols);
doc.close();
writer1.close();
writer2.close();
final FileOutputStream fileStream = new FileOutputStream("C:/Temp/Test2.pdf");
fileStream.write(stream2.toByteArray());
fileStream.close();
stream1.close();
stream2.close();
final OutputStream stream1 = new FileOutputStream("C:/Temp/Test1.pdf");
final PdfWriter writer1 = PdfWriter.getInstance(doc, stream1);
final ByteArrayOutputStream stream2 = new ByteArrayOutputStream();
final PdfWriter writer2 = PdfWriter.getInstance(doc, stream2);
doc.open();
doc.add(new Paragraph("Hallo"));
final MultiColumnText cols = new MultiColumnText();
cols.addRegularColumns(doc.left(), doc.right(), 10f, 3);
for (int i = 0; i < 100; i++) {
cols.addElement(new Paragraph("Hallo"));
}
doc.add(cols);
doc.close();
writer1.close();
writer2.close();
final FileOutputStream fileStream = new FileOutputStream("C:/Temp/Test2.pdf");
fileStream.write(stream2.toByteArray());
fileStream.close();
stream1.close();
stream2.close();
This code make two pdfs for the same document. However, whilst Test1.pdf
does contain the columns added, Test2.pdf doesn't. What's wrong
here?
Thanks in advance
Daniel Frey
