I have code: public class ReportBuilderFactory extends PdfPageEventHelper { /** The Phrase that will be added as the header of the document. */ protected PdfPTable header;
/** The PdfPTable that will be added as the footer of the document. */ protected PdfPTable footer; public ReportBuilderFactory() { header = new PdfPTable(2); header.setTotalWidth(300); header.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER); PdfPCell cl = new PdfPCell(new Phrase("facult: John Smith")); cl.setBorderColor(new Color(255,255,255)); cl.setHorizontalAlignment(Element.ALIGN_CENTER); header.addCell(cl); cl = new PdfPCell(new Phrase("Student: Henry Ford")); cl.setBorderColor(new Color(255,255,255)); cl.setHorizontalAlignment(Element.ALIGN_CENTER); header.addCell(cl); cl = new PdfPCell(new Phrase("Date: 12/31/2006")); cl.setBorderColor(new Color(255,255,255)); cl.setHorizontalAlignment(Element.ALIGN_CENTER); header.addCell(cl); cl = new PdfPCell(new Phrase("Title: Evaluation")); cl.setBorderColor(new Color(255,255,255)); cl.setHorizontalAlignment(Element.ALIGN_CENTER); header.addCell(cl); cl = new PdfPCell(new Phrase("auther: Lloyl Carr")); cl.setBorderColor(new Color(255,255,255)); cl.setHorizontalAlignment(Element.ALIGN_CENTER); header.addCell(cl); cl = new PdfPCell(new Phrase("Done: Yes")); cl.setBorderColor(new Color(255,255,255)); cl.setHorizontalAlignment(Element.ALIGN_CENTER); header.addCell(cl); footer = new PdfPTable(4); footer.setTotalWidth(300); footer.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER); footer.addCell(new Phrase(new Chunk("First Page") .setAction(new PdfAction(PdfAction.FIRSTPAGE)))); footer.addCell(new Phrase(new Chunk("Prev Page") .setAction(new PdfAction(PdfAction.PREVPAGE)))); footer.addCell(new Phrase(new Chunk("Next Page") .setAction(new PdfAction(PdfAction.NEXTPAGE)))); footer.addCell(new Phrase(new Chunk("Last Page") .setAction(new PdfAction(PdfAction.LASTPAGE)))); } public void buildPdfDocumentFCELC( Document document) throws Exception { String title = "title - test"; String nameFaculty ="nameFaculty"; String evaldateFaculty = ("David Bloom"); String nameStudent = ("Jophn Smith"); String evaldateStudent = "12/31/2006"; Paragraph title1 = new Paragraph(title, FontFactory.getFont(FontFactory.HELVETICA, 12, Font.BOLDITALIC, new Color(0, 0, 255))); title1.setAlignment(Element.ALIGN_CENTER); Chapter chapter1 = new Chapter(title1, 1); chapter1.setNumberDepth(0); //no such method // chapter1.setBookmarkTitle(new String("chapter1.setBookmarkTitle here")); //tname is a section to store evaluator/student names and date PdfPTable tname = new PdfPTable(2); // tname.getDefaultCell().setBorder(Rectangle.LEFT | Rectangle.RIGHT); tname.getDefaultCell().setBorder(0); tname.setWidthPercentage(95); Paragraph p1 = new Paragraph(""); PdfPCell c1 = new PdfPCell(new Paragraph("")); String s1 = new String(""); p1= new Paragraph( "Faculty: "+nameFaculty, FontFactory.getFont(FontFactory.HELVETICA, 10)); p1.setLeading(10f); c1 = new PdfPCell(p1); c1.setBorder(Rectangle.NO_BORDER); tname.addCell(c1); p1 = new Paragraph( "Student: "+nameStudent, FontFactory.getFont(FontFactory.HELVETICA, 10)); p1.setLeading(10f); c1 = new PdfPCell(p1); c1.setBorder(Rectangle.NO_BORDER); tname.addCell(c1); p1 = new Paragraph( "Evaluation Date: "+evaldateFaculty, FontFactory.getFont(FontFactory.HELVETICA, 10)); p1.setLeading(15f); c1 = new PdfPCell(p1); c1.setBorder(Rectangle.NO_BORDER); tname.addCell(c1); p1 = new Paragraph( "Evaluation Date: "+evaldateStudent, FontFactory.getFont(FontFactory.HELVETICA, 10)); p1.setLeading(15f); c1 = new PdfPCell(p1); c1.setBorder(Rectangle.NO_BORDER); tname.addCell(c1); p1 = new Paragraph("F: Faculty Evaluation", FontFactory.getFont(FontFactory.HELVETICA, 10, Font.BOLDITALIC, new Color(0, 0, 255))); p1.setLeading(15f); c1 = new PdfPCell(p1); c1.setBorder(Rectangle.NO_BORDER); tname.addCell(c1); p1 = new Paragraph("S: Student Self-Evaluation", FontFactory.getFont(FontFactory.HELVETICA, 10, Font.BOLDITALIC, new Color(0, 0, 255))); p1.setLeading(15f); c1 = new PdfPCell(p1); c1.setBorder(Rectangle.NO_BORDER); tname.addCell(c1); chapter1.add(tname); com.lowagie.text.pdf.PdfPTable tquestion = new com.lowagie.text.pdf.PdfPTable(9); for (int i=0; i < 10; i++) { tname = new PdfPTable(1); p1 = new Paragraph(""); tname.setWidthPercentage(95); c1 = new PdfPCell(p1); p1.setLeading(130f); c1.setBorder(Rectangle.BOTTOM); tname.addCell(c1); chapter1.add(tname); p1 = new Paragraph("evalQuestion Descr "+i, FontFactory.getFont(FontFactory.HELVETICA, 10)); p1.setLeading(10f); p1.setIndentationLeft(18f); //questionList only retrieve main questions (excluded CHKB needs attention) Section section1 = chapter1.addSection(p1); section1.setNumberDepth(0); } document.add(chapter1); } public void onStartPage(PdfWriter writer, Document document) { PdfContentByte cb = writer.getDirectContent(); header.writeSelectedRows(0, -1, ((document.right() - document.left() - 300) / 2)+ document.leftMargin(), document.top() + 10, cb); } public void onEndPage(PdfWriter writer, Document document) { PdfContentByte cb = writer.getDirectContent(); footer.writeSelectedRows(0, -1, (document.right() - document.left() - 300) / 2 + document.leftMargin(), document.bottom() - 10, cb); } } And: try { Document document = new Document(); ReportBuilderFactory rb = new ReportBuilderFactory(); PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("0.pdf")); writer.setViewerPreferences(PdfWriter.PageLayoutTwoColumnLeft); writer.setPageEvent(rb); document.setMargins(36, 36, 100, 72); document.open(); rb.buildPdfDocumentFCELC(document); document.close(); } catch(DocumentException de) { de.printStackTrace(); System.err.println("document: " + de.getMessage()); } catch(Exception e) { System.err.println(e.toString()); } The header has three rows. The header is overlapped with the contents. How to fix this problem. -Henry ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ iText-questions mailing list iText-questions@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/itext-questions Buy the iText book: http://itext.ugent.be/itext-in-action/