Hello,
I am using Itext to create reports, I have created the layout which includes a table.
try{
Document doc = new Document();
PdfWriter.getInstance(doc, new FileOutputStream("Products.pdf"));
doc.open();
Image image = Image.getInstance("logo.png");
//doc.add(new Paragraph("image"));
doc.add(image);
doc.add(new Paragraph("Registration",FontFactory.getFont(FontFactory.TIMES_ROMAN,18,Font.BOLD,BaseColor.RED)));
doc.add(new Paragraph(new Date().toString()));
doc.add(new Paragraph("------------------------------------------------------------------"));
PdfPTable table = new PdfPTable(2);
PdfPCell cell = new PdfPCell(new Paragraph("Teacher name & Stage"));
cell.setColspan(4);
cell.setHorizontalAlignment(Element.ALIGN_CENTER);
cell.setBackgroundColor(BaseColor.GREEN);
table.addCell(cell);
table.addCell("item1");
table.addCell("item2");
table.addCell("item3");
table.addCell("item4");
doc.add(table);
JOptionPane.showMessageDialog(null, "Report Saved!");
doc.close();
}catch(Exception e){
e.printStackTrace();
}
I would like to have the values of my table product-tbl(mysql) in the table. How can I do that?