Dear All,
I am using iText-5.0.4.jar
I have a clarification. I have a list of Employee status (Employee name
and their status as a Bean object). I need to populate
that in a table with 2 columns as follows.
+-------------------------------+----------------------+
+ Employee Name + Status |
+-------------------------------+----------------------+
| Jhon + retired |
| Briyan + working |
+-------------------------------+----------------------+
My query is that, i need to add this header (Employee Name +
Status ) in every page and need to add footer in every page(Page 1 of
23). Just find the present code as follows. Please help me out with
your knowledge.
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
CODE SNIPPET:-
=============
response.setContentType("application/pdf");
document = new Document(PageSize.A4);
/** Finalizing Font for the document **/
titleFont = FontFactory.getFont(COURIER, 14, Font.BOLD);
headerFont = FontFactory.getFont(COURIER, 12);
contentFont = FontFactory.getFont(COURIER,10);
document.setMargins(25F,25F,25F,25F);
/** Writes the document contents to the
ByteArrayOutputStream */
baos = new ByteArrayOutputStream();
PdfWriter.getInstance(document, baos);
document.open();
int[] columnWidths = new int{85,15};
/** Table For header address */
pdfPHeaderTable = new PdfPTable(2);
PdfPCell tableTitle = new PdfPCell (new
Paragraph ("Employee
Report",titleFont));
tableTitle.setColspan(2);
tableTitle.setHorizontalAlignment(Element.ALIGN_CENTER);
pdfPHeaderTable.getDefaultCell().setBorder(PdfPCell.NO_BORDER);
pdfPHeaderTable.addCell(tableTitle);
document.add(pdfPHeaderTable);
/** Title Cell - Ends **/
document.add(new Paragraph(" "));
/** Table Header Cell - Starts**/
PdfPCell headerCellCol1 = new PdfPCell();
headerCellCol1.setHorizontalAlignment(Element.ALIGN_CENTER);
headerCellCol1.addElement(new
Paragraph("Employee Name",headerFont));
PdfPCell headerCellCol2 = new PdfPCell();
headerCellCol2.setHorizontalAlignment(Element.ALIGN_CENTER);
headerCellCol2.addElement(new
Paragraph("Status",headerFont));
/** Table Header Cell - Ends**/
MstrList = new ArrayList<EmployeestatusDO>(0);
MstrList = (List<EmployeestatusDO>)
getSession().get(SessionKeys.MASTER_EMPLOYEE_LIST);
PdfPTable pdfPTable = null;
pdfPTable = new PdfPTable(2);
pdfPTable.addCell(headerCellCol1);
pdfPTable.addCell(headerCellCol2);
/** Table Content Cell **/
for (EmployeestatusDO employeestatusDO : MstrList) {
PdfPCell DetailCell = new PdfPCell();
DetailCell.addElement(new
Paragraph(employeestatusDO.getEmployeeName(), contentFont));
PdfPCell StatusCell = new PdfPCell();
StatusCell.addElement(new
Paragraph(employeestatusDO.getStatus(),
contentFont));
pdfPTable.addCell(DetailCell);
pdfPTable.addCell(StatusCell);
}
document.add(pdfPTable);
document.close();
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Regards,
JP
------------------------------------------------------------------------------
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store
http://p.sf.net/sfu/nokia-dev2dev
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
Many questions posted to this list can (and will) be answered with a reference
to the iText book: http://www.itextpdf.com/book/
Please check the keywords list before you ask for examples:
http://itextpdf.com/themes/keywords.php