Dirk Ulrich wrote:
See the attached GIF to see what I want to achieve (the first cell with the traffic light).
Then you shouldn't put the image and the text into separate Paragraph objects. You should put both inside a Phrase. Use the offset passed to the Chunk constructor (along with the image) to position the image (in my example, it isn't exactly in the middle, you have to take the leading of the text into account too). br, Bruno
dirk_ulrich.pdf
Description: Adobe PDF document
package test; import java.io.FileOutputStream; import java.io.IOException; import com.lowagie.text.Chunk; import com.lowagie.text.Document; import com.lowagie.text.DocumentException; import com.lowagie.text.Element; import com.lowagie.text.Image; import com.lowagie.text.Paragraph; import com.lowagie.text.Phrase; import com.lowagie.text.pdf.PdfPCell; import com.lowagie.text.pdf.PdfPTable; import com.lowagie.text.pdf.PdfWriter; public class DirkUlrich { public static void main(String[] args) { // step 1: creation of a document-object Document document = new Document(); try { // step 2: // we create a writer PdfWriter.getInstance( // that listens to the document document, // and directs a PDF-stream to a file new FileOutputStream("dirk_ulrich.pdf")); // step 3: we open the document document.open(); // step 4: we add a table to the document Image img = Image.getInstance("fflogo.jpg"); PdfPTable table = new PdfPTable(1); Phrase p = new Phrase(); p.add(new Chunk(img, 0, - img.height() / 2)); p.add(" some more text."); PdfPCell cell = new PdfPCell(p); cell.setFixedHeight(img.height() + 6); cell.setPadding(3); table.addCell(cell); document.add(table); } catch (DocumentException de) { System.err.println(de.getMessage()); } catch (IOException ioe) { System.err.println(ioe.getMessage()); } // step 5: we close the document document.close(); } }
------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________ iText-questions mailing list iText-questions@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/itext-questions