Heya, I'm trying to display multiple images on a single line in iText in order to replicate the behavior of a web renderer. I tried to do this by wrapping the images in Chunk object, which are themselves placed in the same Paragraph object. However, when there are a lot of images to be displayed, the images get clipped at the bottom of the page. What am I doing wrong? How can I prevent this? I searched through the book and the mailing list archives, but couldn't figure what was wrong.
Attached is a sample PDF, and follows is the code used to generate it: package com.apollo.art.test; import java.awt.Color; import java.awt.Graphics; import java.awt.image.BufferedImage; import java.io.FileOutputStream; import com.lowagie.text.Chunk; import com.lowagie.text.Document; import com.lowagie.text.Image; import com.lowagie.text.PageSize; import com.lowagie.text.Paragraph; import com.lowagie.text.Phrase; import com.lowagie.text.pdf.PdfWriter; public class PDFTest { public static void main(String[] args) { try { new PDFTest().run(); System.out.println("Generation done."); } catch (final Exception e) { e.printStackTrace(); } } public void run() throws Exception { // Setup document final Document doc = new Document(PageSize.LETTER); final PdfWriter writer = PdfWriter.getInstance(doc, new FileOutputStream("test.pdf")); doc.open(); // Create a sample image final BufferedImage img = new BufferedImage(170, 170, BufferedImage.TYPE_INT_RGB); final Graphics graphics = img.getGraphics(); graphics.setColor(Color.BLUE); graphics.fillRect(0, 0, 170, 170); graphics.setColor(Color.GREEN); graphics.fillOval(100, 100, 90, 90); graphics.setColor(Color.BLACK); graphics.drawRect(0, 0, 169, 169); // Create pdf document final Paragraph paragraph = new Paragraph(); for (int i = 0; i < 20; i++) { final Image image = Image.getInstance(img, null); paragraph.add(new Phrase(new Chunk(image, 0, 0, true))); } doc.add(paragraph); doc.close(); } } Mathieu Mallet *Apollo Systems Research Corporation*
test.pdf
Description: Adobe PDF document
------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________ iText-questions mailing list iText-questions@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/itext-questions Buy the iText book: http://itext.ugent.be/itext-in-action/