Apache Geronimo和Spring框架,第6部分:Spring MVC:使用Web视图技术 - 编程入门网
作者 佚名技术
来源 NET编程
浏览
发布时间 2012-06-14
ldPdfDocument( Map model, Document doc, PdfWriter writer, HttpServletRequest req, HttpServletResponse resp) throws Exception { List phonebook = (List) model.get("phonebook"); String title = "Phone Book"; Paragraph h1 = new Paragraph(title, HEADLINE_FONT); h1.setAlignment(Paragraph.ALIGN_CENTER); doc.add(h1); doc.add(new Paragraph(" ")); doc.add(new Paragraph(" ")); doc.add(new Paragraph(" ")); // We create a table for used criteria and extracting information PdfPTable table = new PdfPTable(NO_OF_COLUMNS); int headerwidths[] = {20, 20, 20, 20, 20}; table.setWidths(headerwidths); table.setWidthPercentage(100); table.getDefaultCell().setBorderWidth(1); table.getDefaultCell().setBorderColor(Color.black); table.getDefaultCell().setPadding(3); table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER); table.getDefaultCell().setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(new Phrase("Name", DATA_HEAD_FONT)); table.addCell(new Phrase("Home Phone", DATA_HEAD_FONT)); table.addCell(new Phrase("Work Phone", DATA_HEAD_FONT)); table.addCell(new Phrase("Cell Phone", DATA_HEAD_FONT)); table.addCell(new Phrase("Email", DATA_HEAD_FONT)); // We set the above row as title // and adjust properties for normal cells table.setHeaderRows(1); table.getDefaultCell().setBorderWidth(1); // We iterate now on the Phonebook list Iterator it = phonebook.iterator(); while(it.hasNext()) { PhonebookEntry pEntry = (PhonebookEntry) it.next(); table.addCell(new Phrase(pEntry.getFirstName() + " " + pEntry.getLastName(), TEXT_FONT)); table.addCell(new Phrase(pEntry.getHomeNumber(), TEXT_FONT)); table.addCell(new Phrase(pEntry.getWorkNumber(), TEXT_FONT)); table.addCell(new Phrase(pEntry.getCellNumber(), TEXT_FONT)); table.addCell(new Phrase(pEntry.getEmail(), TEXT_FONT)); } doc.add(table); doc.add(new Paragraph(" ")); doc.add(new Paragraph(" ")); doc.add(new Paragraph(" ")); doc.add(new Paragraph(" ")); String footerStr1 = "This example is developed to demonstrate the Spring framework on the Geronimo Application Server."; String footerStr2 = "This example is designed purely for demonstrating the capabilities of the framework. It should under no circumstances be |
凌众科技专业提供服务器租用、服务器托管、企业邮局、虚拟主机等服务,公司网站:http://www.lingzhong.cn 为了给广大客户了解更多的技术信息,本技术文章收集来源于网络,凌众科技尊重文章作者的版权,如果有涉及你的版权有必要删除你的文章,请和我们联系。以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢! |
你可能对下面的文章感兴趣
关于Apache Geronimo和Spring框架,第6部分:Spring MVC:使用Web视图技术 - 编程入门网的所有评论