Leading and PDFPTables and PDFPCells
- From: Scott McKenzie <Scott_McKenzie (at) hermanmiller.com>
- Date: Wed, 16 Aug 2006 09:37:36 -0400
I am having trouble getting leading to work within PDFPTable / PDFPCell. It appears to be ignoring leading no matter what level I place it at. If I remove the ImageI saw a few other posts in regard
to this but none really answered my question. The code follows...
public Document CreateChapterPages(Document document, Properties aProperties, Book aBook)
throws DocumentException {
int itemsOnPage = 0;
boolean bCreateHeader = true;
DAO aDAO = new DAO();
Chapter aChapter = null;
List chaptersList = aDAO.getChaptersByType(aBook.getBookId(),"'P'"); // Get all chapters
PdfPTable table = new PdfPTable(5);
PdfPCell cell = new PdfPCell();
for (int i = 0; i < chaptersList.size(); i++) { // Iterate through chapters
cell = new PdfPCell();
cell.setNoWrap(false);
cell.setLeading(.5f, 1.0f);
itemsOnPage++;
if (bCreateHeader) {
document.add(table);
document.newPage();
itemsOnPage = 1;
bCreateHeader = false;
document = CreateFrontPageHeader(document, aBook, aProperties);
}
aChapter = (Chapter) chaptersList.get(i);
cell.setBorder(0); // Hide table border
cell.setFixedHeight(200);
table.getDefaultCell().setLeading(.5f, 1.0f);
try {
Image jpg = Image.getInstance(aProperties.getImageSrc() + aChapter.getChapterThumbnailImage()); // Get the image from the file system
jpg.scalePercent(aProperties.getThumbNailScale()); // Scale image
jpg.setAlignment(Element.ALIGN_CENTER); // Center justify
cell.addElement(jpg);
cell.setLeading(.5f, 1.0f);
} catch (IOException ioe) {
System.err.println(ioe.getMessage());
}
cell.addElement(new Chunk("Chapter " + (i+1) + ". ", // Display chapter number
FontFactory.getFont(FontFactory.HELVETICA, 10)));
cell.setLeading(.5f, 1.0f);
cell.addElement(new Chunk(aChapter.getChapterTitle(), // Display chapter title
FontFactory.getFont(FontFactory.HELVETICA_BOLD, 10)));
cell.setLeading(.5f, 1.0f);
table.addCell(cell);
if (itemsOnPage == 10 ) { // 10 items per page
bCreateHeader = true;
}
}
document.add(table);
return document;
}
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
iText-questions mailing list
iText-questions (at) lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions