/*
* $Id$
*
* This code is part of the 'iText Tutorial'.
* You can find the complete tutorial at the following address:
* http://itextdocs.lowagie.com/tutorial/
*
* This code is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* itext-questions@lists.sourceforge.net
*/
package com.lowagie.examples.objects.tables;
import java.io.IOException;
import com.lowagie.text.LwgDocument;
import com.lowagie.text.DocumentException;
import com.lowagie.text.LwgImage;
import com.lowagie.text.pdf.LwgPdfPCell;
import com.lowagie.text.pdf.LwgPdfPTable;
import com.lowagie.text.pdf.PdfWriter;
import org.geoforge.demo.GfrFileOutputStream;
/**
* A cell with an LwgImage.
*/
public class ImageCell {
/**
* A cell with an image.
*
* @param args
* no arguments needed
*/
public static void main(String[] args) {
System.out.println("Image in a Cell");
// step 1: creation of a document-object
LwgDocument document = new LwgDocument();
try {
// step 2:
PdfWriter.getInstance(document, new GfrFileOutputStream("com.lowagie.examples.objects.tables.ImageCell.pdf"));
// step 3: we open the document
document.open();
LwgImage image = LwgImage.getInstance("otsoe.jpg");
float[] widths = {1f, 4f};
LwgPdfPTable table = new LwgPdfPTable(widths);
table.add("This is my dog");
table.add(image);
table.add("This two");
table.add(new LwgPdfPCell(image, true));
table.add("This three");
table.add(new LwgPdfPCell(image, false));
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();
}
}