Hi Raffaele, thanks for your quick reply.
This are great news. I downloaded PdfDocument and PdfChunk (which is also different from 1.4.7) and the TestCase runs fine. Christian -------- Original-Nachricht -------- Datum: Thu, 14 Dec 2006 09:48:21 +0100 Von: "GAMBELLI Raffaele" <[EMAIL PROTECTED]> An: "Post all your questions about iText here" <[email protected]> Betreff: Re: [iText-questions] Long table on page with header causes empty page > Bruno has already answered: > > Bruno said: > > OK, I think I have fixed it. The fix is in the CVS. > > (There could be side-effects, but I have tested the > > fix with different examples and the results were fine.) > > I'll make a release next week (after JavaPolis). > > Meanwhile you can test it by downloading the new > > version of PdfDocument and compile iText from the source. > > br, > > Bruno > > -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] Behalf Of > Christian Hufgard > Sent: giovedì 14 dicembre 2006 9.45 > To: [email protected] > Subject: [iText-questions] Long table on page with header causes empty > page > > > Hi everyone, > > I found something in iText (1.4.7) that might be a bug (or wrong use, of > course...) > > When creating a long table that has to be wrapped on the next page > basically everything works fine. The table is wrapped broken into two parts. > > Now if I add a header to the document, I get a third _empty_ page added to > my document. > > Here is a simple junit-test that creates two files in the temp dir named > long_table_without_header.pdf and long_table_with_header.pdf that show the > problem. > The test creates a document with a table containing 60 cells. In the first > test it does not add a header, in the second test it does. After having > written the document to the temp dir, it validates if the created document > contains two pages. In the first test it does, in the second it does not. > > If I am doing anything wrong, please give me a clue. Otherwise a bugfix or > workaround would be great. > > > Christian > > > > Here comes the TestCase: > > import java.io.ByteArrayOutputStream; > import java.io.File; > import java.io.FileNotFoundException; > import java.io.FileOutputStream; > import java.io.IOException; > > import junit.framework.TestCase; > > import com.lowagie.text.Cell; > import com.lowagie.text.Document; > import com.lowagie.text.DocumentException; > import com.lowagie.text.HeaderFooter; > import com.lowagie.text.Phrase; > import com.lowagie.text.Table; > import com.lowagie.text.pdf.PdfReader; > import com.lowagie.text.pdf.PdfWriter; > > > /** > * @author cch > */ > public class CreatePagesWithTables extends TestCase > { > public void testTableWithoutHeader() > throws Exception > { > createPDF(false); > } > > public void testTableWithHeader() > throws Exception > { > createPDF(true); > } > > public void createPDF(boolean addHeader) > throws DocumentException, IOException > { > ByteArrayOutputStream baos = new ByteArrayOutputStream(); > > Document document = new Document(); > > PdfWriter.getInstance(document, baos); > > if (addHeader) > { > addHeader(document); > } > > document.open(); > > addTable(document); > > document.close(); > > byte[] pdf = baos.toByteArray(); > > PdfReader pdfReader = new PdfReader(pdf); > int pages = pdfReader.getNumberOfPages(); > > storePdf(pdf, addHeader); > > assertEquals(2, pages); > } > > private void addTable(Document document) > throws DocumentException > { > Table table = new Table(1); > for (int i = 0; i < 60; i++) { > table.addCell(new Cell("cell "+i)); > } > document.add(table); > } > > private void addHeader(Document document) > { > HeaderFooter header = new HeaderFooter(new Phrase("Just a dumb > header"), false); > header.setBorderWidth(1f); > header.setBorder(HeaderFooter.BOX); > header.setAlignment(HeaderFooter.ALIGN_LEFT); > > document.setHeader(header); > } > > private void storePdf(byte[] pdf, boolean addHeader) > throws FileNotFoundException, IOException > { > String tmpDir = System.getProperty("java.io.tmpdir"); > String filename = > tmpDir+File.separator+"long_table_"+(addHeader?"with_header":"without_header")+".pdf" > ; > new FileOutputStream(filename).write(pdf); > } > } > -- > "Ein Herz für Kinder" - Ihre Spende hilft! Aktion: > www.deutschlandsegelt.de > Unser Dankeschön: Ihr Name auf dem Segel der 1. deutschen America's > Cup-Yacht! > > ------------------------------------------------------------------------- > 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/ > > ------------------------------------------------------------------------- > 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/ -- "Ein Herz für Kinder" - Ihre Spende hilft! Aktion: www.deutschlandsegelt.de Unser Dankeschön: Ihr Name auf dem Segel der 1. deutschen America's Cup-Yacht! ------------------------------------------------------------------------- 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/
