Thanks guys. Got it working. Sorry for the confusing code. I probably should of explained that the text has already been parsed to fit an A4 page and is being stored within a custom object. Which is why I was checking whether another page is required I admit an extremely hacky and messy way to do so, but its been purged after reading Benjamin's example.
Once again cheers for the examples they were a big help and hopefully I'll get time to read iText in Action and not be making such foolish mistakes. Regards Kevin Benjamin Rein wrote: > > Hi Kevin, > > please have a look at the following tutorial: > http://stderr.org/doc/libitext-java-doc/www/tutorial/ch10.html > > Example 7 deals exactly with your problem. > > Best Regards > Benjamin > > > *Kevin Logue <[email protected]>* > > 21.01.2009 15:39 > Bitte antworten an > Post all your questions about iText here > <[email protected]> > > > > An > [email protected] > Kopie > > Thema > [iText-questions] Multiple Page Headache using ColumnText > > > > > > > > > > Hi > > Sorry I'm new to using iText so my apologies if the below code is an > abomination to all things iText. > My problem is simple, when there is only one page to render the pdf is > created flawlessly. However > when I go to a second page the ColumnText seems to be appearing at the > very bottom of the second > page with the rest of the text(presumably rendered off-screen, the > document will only ever be one or > two pages). > > I'm using an onStartPage event to render a background image(covering the > entire page) to the > DirectContentUnder. If I'm doing anything particularly weird I'd > appreciate the feedback on > how to improve the code/technique. > > Regards > Kevin > > The Abomination follows.... > ----------------------------------------------------- > document.open(); > PdfContentByte topLayer = writer.getDirectContent(); > try { > topLayer.setFontAndSize(BaseFont.createFont(), 9f); > } catch (IOException e) { > log.error(e); > } > > ColumnText column = new ColumnText(topLayer); > > column.setSimpleColumn(HORIZONTALINDENT, VERTICALINDENT, > document.right() - HORIZONTALINDENT, document.top() - VERTICALINDENT, > 0f, Element.ALIGN_CENTER); > > for(int i=0; i < getNumPages(); i++) > { > float lineSpacing = 9f; > Font textfont = new Font(Font.COURIER , 9f, Font.NORMAL); > Paragraph paraText= new Paragraph( getPage(i).toString(), textfont); > > paraText.setLeading(lineSpacing); > paraText.setSpacingBefore(0f); > paraText.setSpacingAfter(0f); > column.addElement(paraText); > column.go(); > > if(i+1 < getNumPages()){ > document.newPage(); > topLayer.reset(); > } > } > document.close(); > > > > ------------------------------------------------------------------------------ > This SF.net email is sponsored by: > SourcForge Community > SourceForge wants to tell your story. > http://p.sf.net/sfu/sf-spreadtheword > _______________________________________________ > iText-questions mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/itext-questions > > Buy the iText book: http://www.1t3xt.com/docs/book.php > > > > > > ____________________________________________________________________ > > Viessmann IT Service GmbH > Geschäftsführer: Dirk Klöckner, Dr. Harald Dörnbach > Sitz der Gesellschaft: Allendorf (Eder) - Registergericht: > AG Marburg (Lahn) - HRB 5324 - USt-IdNr.: DE258558424 > ____________________________________________________________________ > ------------------------------------------------------------------------ > > ------------------------------------------------------------------------------ > This SF.net email is sponsored by: > SourcForge Community > SourceForge wants to tell your story. > http://p.sf.net/sfu/sf-spreadtheword > > > __________ Information from ESET NOD32 Antivirus, version of virus signature > database 3785 (20090121) __________ > > The message was checked by ESET NOD32 Antivirus. > > http://www.eset.com > > > ------------------------------------------------------------------------ > > _______________________________________________ > iText-questions mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/itext-questions > > Buy the iText book: http://www.1t3xt.com/docs/book.php > > > __________ Information from ESET NOD32 Antivirus, version of virus signature > database 3785 (20090121) __________ > > The message was checked by ESET NOD32 Antivirus. > > http://www.eset.com > > ------------------------------------------------------------------------------ This SF.net email is sponsored by: SourcForge Community SourceForge wants to tell your story. http://p.sf.net/sfu/sf-spreadtheword _______________________________________________ iText-questions mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/itext-questions Buy the iText book: http://www.1t3xt.com/docs/book.php
