Hi Friends,
I am new to itext, i am trying to generate a pdfPTable with 31 columns.The first cell
will contains text and the remaining 30 columns will contains the image.
I am trying to make the text as aligned middle and image should be fit into cell. But it always show
text as bottom aligned and image as top aligned.
If anybody knows the solution please help me
Below is my java main class. Attached images


===============
import java.awt.Color;
import java.io.FileOutputStream;
import java.io.IOException;
import com.lowagie.text.Document;
import com.lowagie.text.DocumentException;
import com.lowagie.text.Element;
import com.lowagie.text.Font;
import com.lowagie.text.Image;
import com.lowagie.text.PageSize;
import com.lowagie.text.Paragraph;
import com.lowagie.text.pdf.PdfPCell;
import com.lowagie.text.pdf.PdfPTable;
import com.lowagie.text.pdf.PdfWriter;
public class CreatePDF {
public static void main(String[] args) {
Document document = new Document(PageSize.A4.rotate(),10, 10, 10, 10);
try {
PdfWriter.getInstance(document, new FileOutputStream("ImageCell.pdf",true));
Image redImage = Image.getInstance("red1.jpg");
Image blueImage = Image.getInstance("blue1.jpg");
document.open();
PdfPTable table = new PdfPTable(32);
for(int i=0; i<5; i++){
PdfPCell headCEll = new PdfPCell();
headCEll.setBorder(0);
headCEll.setBackgroundColor(Color.red);
headCEll.setColspan(2);
Font f = new Font(8);
f.setSize(8);
Paragraph p = new Paragraph("Analysis",f);
headCEll.addElement(p);
headCEll.setVerticalAlignment(Element.ALIGN_MIDDLE);
table.addCell(headCEll);
for(int j=0; j<15; j++){
PdfPCell redCEll = new PdfPCell();
redCEll.setImage(redImage);
redCEll.setBorder(0);
redCEll.setBackgroundColor(Color.blue);
table.addCell(redCEll);
PdfPCell blueCEll = new PdfPCell();
blueCEll.setImage(blueImage);
blueCEll.setBackgroundColor(Color.red);
blueCEll.setBorder(0);
table.addCell(blueCEll);
}
}
document.add(table);
} catch (DocumentException de) {
System.err.println(de.getMessage());
} catch (IOException ioe) {
System.err.println(ioe.getMessage());
}
document.close();
System.out.println("Image in a Cell");
}
}
=====================
regards,
Manju.