List of usage examples for com.itextpdf.text Paragraph setSpacingAfter
public void setSpacingAfter(float spacing)
From source file:com.masscustsoft.service.ToPdf.java
License:Open Source License
private com.itextpdf.text.List getList(Map row) throws Exception { String type = (String) row.get("type"); com.itextpdf.text.List list = null; if ("greek".equals(type)) list = new GreekList(); else if ("roman".equals(type)) list = new RomanList(); else if ("zd".equals(type)) list = new ZapfDingbatsList(1); else if ("zd#".equals(type)) list = new ZapfDingbatsNumberList(1); else/* w w w.j ava2 s. c o m*/ list = new com.itextpdf.text.List(); Integer charNumber = (Integer) row.get("charNumber"); if (charNumber != null) { if (list instanceof ZapfDingbatsList) { ((ZapfDingbatsList) list).setCharNumber(charNumber); } if (list instanceof ZapfDingbatsNumberList) { ((ZapfDingbatsNumberList) list).setType(charNumber); } } Boolean lowercase = (Boolean) row.get("lowercase"); if (lowercase != null) list.setLowercase(lowercase); Boolean numbered = (Boolean) row.get("numbered"); if (numbered != null) list.setNumbered(numbered); Boolean lettered = (Boolean) row.get("lettered"); if (lettered != null) list.setLettered(lettered); Integer first = (Integer) row.get("first"); if (first != null) list.setFirst(first); String symbol = (String) row.get("symbol"); if (symbol != null) { Paragraph p = new Paragraph(); getChunks(p, row, symbol); if (p.size() > 0) { Object sym = p.get(0); if (sym instanceof Chunk) { list.setListSymbol((Chunk) sym); } } } Float ident = (Float) row.get("ident"); if (ident == null) ident = 10f; list.setSymbolIndent(ident); List<Map> lst = (List) row.get("items"); if (lst != null) { for (Map item : lst) { Element el = getElement(item); if (el != null) { ListItem li = new ListItem(); li.add(el); list.add(li); } } } if (list.size() > 0) { Object o = list.getItems().get(0); if (o instanceof Paragraph) { Paragraph p = (Paragraph) o; Float spaceBefore = (Float) row.get("spaceBefore"); if (spaceBefore != null) p.setSpacingBefore(spaceBefore); } o = list.getItems().get(list.getItems().size() - 1); if (o instanceof Paragraph) { Paragraph p = (Paragraph) o; Float spaceAfter = (Float) row.get("spaceAfter"); if (spaceAfter != null) p.setSpacingAfter(spaceAfter); } } return list; }
From source file:com.maxl.java.amikodesk.SaveBasket.java
License:Open Source License
public void generatePdf(Author author, String filename, String type) { // A4: 8.267in x 11.692in => 595.224units x 841.824units (72units/inch) // marginLeft, marginRight, marginTop, marginBottom Document document = new Document(PageSize.A4, 50, 50, 80, 50); try {/*from w ww. java 2 s .c om*/ if (m_shopping_basket.size() > 0) { PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(filename)); writer.setBoxSize("art", new Rectangle(50, 50, 560, 790)); HeaderFooter event = new HeaderFooter(); writer.setPageEvent(event); document.open(); PdfContentByte cb = writer.getDirectContent(); document.addAuthor("ywesee GmbH"); document.addCreator("AmiKo for Windows"); document.addCreationDate(); // Logo String logoImageStr = m_prefs.get(LogoImageID, Constants.IMG_FOLDER + "empty_logo.png"); File logoFile = new File(logoImageStr); if (!logoFile.exists()) logoImageStr = Constants.IMG_FOLDER + "empty_logo.png"; Image logo = Image.getInstance(logoImageStr); logo.scalePercent(30); logo.setAlignment(Rectangle.ALIGN_RIGHT); document.add(logo); document.add(Chunk.NEWLINE); // Bestelladresse // --> String bestellAdrStr = m_prefs.get(BestellAdresseID, m_rb.getString("noaddress1")); String bestellAdrStr = getAddressAsString(BestellAdresseID); Paragraph p = new Paragraph(12); // p.setIndentationLeft(60); p.add(new Chunk(bestellAdrStr, font_norm_10)); document.add(p); document.add(Chunk.NEWLINE); // Title p = new Paragraph(m_rb.getString("order"), font_bold_16); document.add(p); // Date DateFormat dateFormat = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss"); Date date = new Date(); p = new Paragraph(m_rb.getString("date") + ": " + dateFormat.format(date), font_bold_10); p.setSpacingAfter(20); document.add(p); // document.add(Chunk.NEWLINE); // Add addresses (Lieferadresse + Rechnungsadresse) /* --> OLD String lieferAdrStr = m_prefs.get(LieferAdresseID, m_rb.getString("noaddress2")); String rechnungsAdrStr = m_prefs.get(RechnungsAdresseID, m_rb.getString("noaddress3")); */ // --> NEW String lieferAdrStr = getAddressAsString(LieferAdresseID); String rechnungsAdrStr = getAddressAsString(RechnungsAdresseID); PdfPTable addressTable = new PdfPTable(new float[] { 1, 1 }); addressTable.setWidthPercentage(100f); addressTable.getDefaultCell().setPadding(5); addressTable.setSpacingAfter(5f); addressTable.addCell(getStringCell(m_rb.getString("shipaddress"), font_bold_10, PdfPCell.NO_BORDER, Element.ALIGN_MIDDLE, 1)); addressTable.addCell(getStringCell(m_rb.getString("billaddress"), font_bold_10, PdfPCell.NO_BORDER, Element.ALIGN_MIDDLE, 1)); addressTable.addCell( getStringCell(lieferAdrStr, font_norm_10, PdfPCell.NO_BORDER, Element.ALIGN_MIDDLE, 1)); addressTable.addCell( getStringCell(rechnungsAdrStr, font_norm_10, PdfPCell.NO_BORDER, Element.ALIGN_MIDDLE, 1)); document.add(addressTable); document.add(Chunk.NEWLINE); // Add shopping basket if (type.equals("specific")) document.add(getShoppingBasketForAuthor(author, cb)); else if (type.equals("all")) document.add(getFullShoppingBasket(cb, "all")); else if (type.equals("rest")) document.add(getFullShoppingBasket(cb, "rest")); LineSeparator separator = new LineSeparator(); document.add(separator); } } catch (IOException e) { } catch (DocumentException e) { } document.close(); // System.out.println("Saved PDF to " + filename); }
From source file:com.pma.mpsr.export.PDFGenerator.java
/** * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse * response)//from ww w.ja v a 2s . co m */ @Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String mpsrID = request.getParameter("MPSR_ID"); if (null == mpsrID) return; MPSRProjectInfo basicInfo = MPSRProjectInfo.getInstance(mpsrID); MPSRExecutiveSummary exeSummary = MPSRExecutiveSummary.getInstance(mpsrID); MPSRStatusSummary statusSummary = MPSRStatusSummary.getInstance(mpsrID); MPSRFunctionPerformance funcPerform = MPSRFunctionPerformance.getInstance(mpsrID); MPSRCostPerformance costPerform = MPSRCostPerformance.getInstance(mpsrID); MPSRSchedulePerformance[] schedulePerform = MPSRSchedulePerformance.getInstance(mpsrID); MPSRSafety safety = MPSRSafety.getInstance(mpsrID); MPSRAuthorization auth = MPSRAuthorization.getInstance(mpsrID); MPSRBudget budget = MPSRBudget.getInstance(mpsrID); MPSRCostReport[] costRpt = MPSRCostReport.getInstance(mpsrID); MPSRSchedule schedule = MPSRSchedule.getInstance(mpsrID); MPSRMilestone[] milestones = MPSRMilestone.getInstance(mpsrID); MPSRLPE lpe = MPSRLPE.getInstance(mpsrID); MPSRInsidePlantDesign[] ipds = MPSRInsidePlantDesign.getInstance(mpsrID); MPSROutsidePlantDesign[] opds = MPSROutsidePlantDesign.getInstance(mpsrID); MPSRProcure procure = MPSRProcure.getInstance(mpsrID); MPSRApprovedChanges[] approvedChanges = MPSRApprovedChanges.getInstance(mpsrID); MPSRPendingChanges[] pendingChanges = MPSRPendingChanges.getInstance(mpsrID); MPSRInsidePlantConstruction[] ipcs = MPSRInsidePlantConstruction.getInstance(mpsrID); MPSROutsidePlantConstruction[] opcs = MPSROutsidePlantConstruction.getInstance(mpsrID); MPSRAppendix[] appendixs = MPSRAppendix.getInstance(mpsrID); MPSRAttachment[] attachments = MPSRAttachment.getInstance(mpsrID); // response.setContentType("application/pdf"); // response.setHeader("Content-Disposition", // "attachment; filename=\"test.pdf\""); Font fontNormal = null; Font fontCoverTitle = new Font(FontFamily.HELVETICA, 20, Font.BOLD); Font fontCoverTableHeader = new Font(FontFamily.HELVETICA, 16, Font.BOLD); Font fontCoverTableContent = new Font(FontFamily.HELVETICA, 16); Font fontChapterHeader = new Font(FontFamily.HELVETICA, 18, Font.BOLD); Font fontSection1Header = new Font(FontFamily.HELVETICA, 16, Font.BOLD); Font fontSection2Header = new Font(FontFamily.HELVETICA, 14, Font.BOLD); Font fontWork = new Font(FontFamily.HELVETICA, 12, Font.UNDERLINE); Font fontTableCaption = new Font(FontFamily.TIMES_ROMAN, 12, Font.BOLD); Font fontTableColumnHeader = new Font(FontFamily.HELVETICA, 12, Font.BOLD); Font fontTableColumnHeaderYellow = new Font(FontFamily.HELVETICA, 12, Font.BOLD); fontTableColumnHeaderYellow.setColor(BaseColor.YELLOW); Font fontTableRowTitle = new Font(FontFamily.HELVETICA, 12, Font.ITALIC); Font fontTableCellBold = new Font(FontFamily.HELVETICA, 12, Font.BOLD); Font fontTableNote = new Font(FontFamily.HELVETICA, 10, Font.ITALIC); Font fontImageCaption = new Font(FontFamily.TIMES_ROMAN, 9, Font.BOLD); Font fontPOTableHeader = new Font(FontFamily.HELVETICA, 10, Font.BOLD); fontPOTableHeader.setColor(BaseColor.YELLOW); Font fontPOTable = new Font(FontFamily.HELVETICA, 9); Font fontPOTableSummary = new Font(FontFamily.HELVETICA, 9, Font.BOLD); Font fontPageHeader = new Font(FontFamily.HELVETICA, 8); Font fontPageFooter = new Font(FontFamily.HELVETICA, 10); Phrase[] headerTexts = new Phrase[] { new Phrase("PMA - ELECTRIC DELIVERY", fontPageHeader), new Phrase("DELIVERY PROJECTS & CONSTRUCTION (DP&C)", fontPageHeader), new Phrase("PROJECT MONTHLY REPORT", fontPageHeader) }; Paragraph paragraph = null; PdfPTable table = null; PdfPCell cell = null; Document document = new Document(DEFAULT_PAGE_SIZE, 36, 36, 9 * 10, 36); ByteArrayOutputStream baosOrig = new ByteArrayOutputStream(); XMLWorkerHelper xmlWorker = XMLWorkerHelper.getInstance(); try { PdfWriter writer = PdfWriter.getInstance(document, baosOrig); writer.setStrictImageSequence(true); writer.setLinearPageMode(); writer.setViewerPreferences(PdfWriter.PageModeUseOutlines | PdfWriter.FitWindow); Image icon = getEmbeddedImage(getServletContext(), "/resource/image/pma.bmp"); document.open(); PdfOutline root = writer.getRootOutline(); // *******************************************************************************************// // addOutline(root, writer, MPSRUI.TREE_0); for (int i = 0; i < 2; i++) { document.add(new Paragraph(" ")); } String[] titles = { "PMA DELIVERY PROJECTS & CONSTRUCTION", "MONTHLY REPORT", basicInfo.getReportMonthYear(), basicInfo.getProjectTitle(), "PROJECT No. " + basicInfo.getProjectDefinition() }; int[] spaceingAfters = { 48, 48, 48, 24, 48 }; for (int i = 0; i < titles.length; i++) { paragraph = new Paragraph(); paragraph.setSpacingAfter(spaceingAfters[i]); paragraph.setFont(fontCoverTitle); paragraph.setAlignment(Element.ALIGN_CENTER); paragraph.add(new Chunk(titles[i])); document.add(paragraph); } addCoverImage(document, MPSRUI.getFilePath(mpsrID, basicInfo.getFileName())); document.add(new Paragraph(" ")); table = new PdfPTable(2); table.addCell(new Phrase("Client", fontCoverTableHeader)); table.addCell(new Phrase(basicInfo.getProjectManager(), fontCoverTableContent)); table.addCell(new Phrase("Location", fontCoverTableHeader)); table.addCell(new Phrase(basicInfo.getProjectDirector(), fontCoverTableContent)); document.add(table); // *******************************************************************************************// document.resetPageCount(); document.add(Chunk.NEXTPAGE); writer.setPageEvent(new MPSRPageEventHelper(icon, headerTexts, fontPageFooter)); // *******************************************************************************************// PdfOutline outline1 = addOutline(root, writer, MPSRUI.TREE_1); addSectionTitle(document, MPSRUI.TREE_1, fontChapterHeader, 0, 0, 12); PdfOutline outline2 = addOutline(outline1, writer, "1.1"); addOutline(outline2, writer, MPSRUI.TREE_1_1_1); addSectionTitle(document, MPSRUI.TREE_1_1_1, fontSection2Header, 12, 12, 0); addParagraph(document, writer, xmlWorker, exeSummary.getDesc_1_1_1(), fontNormal, 12, 0, 12); addOutline(outline2, writer, MPSRUI.TREE_1_1_2); addSectionTitle(document, MPSRUI.TREE_1_1_2, fontSection2Header, 12, 12, 0); addParagraph(document, writer, xmlWorker, exeSummary.getDesc_1_1_2(), fontNormal, 12, 0, 12); addOutline(outline2, writer, MPSRUI.TREE_1_1_3); addSectionTitle(document, MPSRUI.TREE_1_1_3, fontSection2Header, 12, 12, 0); addParagraph(document, writer, xmlWorker, exeSummary.getDesc_1_1_3(), fontNormal, 12, 0, 12); addOutline(outline2, writer, MPSRUI.TREE_1_1_4); addSectionTitle(document, MPSRUI.TREE_1_1_4, fontSection2Header, 12, 12, 0); addParagraph(document, writer, xmlWorker, exeSummary.getDesc_1_1_4(), fontNormal, 12, 0, 12); // *******************************************************************************************// // 1.2 Status Summary // *******************************************************************************************// outline2 = addOutline(outline1, writer, MPSRUI.TREE_1_2); addSectionTitle(document, MPSRUI.TREE_1_2, fontSection1Header, 6, 12, 12); paragraph = new Paragraph(); paragraph.add(basicInfo.getProjectTitle()); paragraph.setSpacingAfter(4); document.add(paragraph); table = new PdfPTable(5); table.setTotalWidth(500); table.setLockedWidth(true); table.setWidths(new int[] { 3, 1, 1, 1, 1 }); cell = new PdfPCell( new Phrase("Project #: " + basicInfo.getProjectDefinition(), fontTableColumnHeader)); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); String[] headers = { "Status", "Approved (Include RnC)", "To Date", "At Completion" }; for (String header : headers) { cell = new PdfPCell(new Phrase(header, fontTableColumnHeader)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); } String[][] cellValues = { { "Budget ($M)", statusSummary.getBudgetStatus(), !"".equals(statusSummary.getBudgetApproved()) ? CURRENCY_FORMATTER .format(Double.parseDouble(statusSummary.getBudgetApproved())) : "", !"".equals(statusSummary.getBudgetToDate()) ? CURRENCY_FORMATTER.format(Double.parseDouble(statusSummary.getBudgetToDate())) : "", !"".equals(statusSummary.getBudgetAtCompletion()) ? CURRENCY_FORMATTER .format(Double.parseDouble(statusSummary.getBudgetAtCompletion())) : "" }, { "Schedule - Duration (months)", statusSummary.getScheduleStatus(), statusSummary.getScheduleApproved(), statusSummary.getScheduleToDate(), statusSummary.getScheduleAtCompletion() }, { "In-Service Date", statusSummary.getInServiceDateStatus(), statusSummary.getInServiceDateApproved(), statusSummary.getInServiceDateToDate(), statusSummary.getInServiceDateAtCompletion() } }; for (int i = 0; i < cellValues.length; i++) { table.addCell(new Phrase(cellValues[i][0])); cell = new PdfPCell(new Phrase(cellValues[i][1])); cell.setBackgroundColor(getBackgroundColor(cellValues[i][1])); cell.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(cell); for (int j = 2; j < 5; j++) { cell = new PdfPCell(new Phrase(cellValues[i][j])); cell.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(cell); } } document.add(table); // -------------------------------------------------------------------// paragraph = new Paragraph("Legend:"); paragraph.setSpacingAfter(4); paragraph.setIndentationLeft(25); document.add(paragraph); table = new PdfPTable(3); table.setTotalWidth(240); table.setLockedWidth(true); table.setHorizontalAlignment(Element.ALIGN_LEFT); String[] legends = { "On Target", "At Risk", "Off Target" }; for (String legend : legends) { cell = new PdfPCell(new Phrase(legend)); cell.setBackgroundColor(getBackgroundColor(legend)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); cell.setMinimumHeight(18); cell.setPadding(0); table.addCell(cell); } paragraph = new Paragraph(); paragraph.add(table); paragraph.setIndentationLeft(25); document.add(paragraph); // *******************************************************************************************// // 1.2.1 Functional Area Performance Indicators // *******************************************************************************************// addOutline(outline2, writer, MPSRUI.TREE_1_2_1); addSectionTitle(document, MPSRUI.TREE_1_2_1, fontSection2Header, 12, 12, 12); table = new PdfPTable(4); table.setTotalWidth(550); table.setLockedWidth(true); table.setWidths(new int[] { 4, 1, 1, 4 }); headers = new String[] { "Activities", "Current Status", "Trend", "Comments (main performance drives)" }; for (String header : headers) { cell = new PdfPCell(new Phrase(header, fontTableColumnHeader)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); } Image imgArrowUp = getEmbeddedImage(getServletContext(), "/VAADIN/themes/MPSR/img/Arrow_Up.png"); Image imgArrowDown = getEmbeddedImage(getServletContext(), "/VAADIN/themes/MPSR/img/Arrow_Down.png"); Image imgArrowEven = getEmbeddedImage(getServletContext(), "/VAADIN/themes/MPSR/img/Arrow_Even.png"); Image[] images = { imgArrowUp, imgArrowDown, imgArrowEven }; for (Image image : images) { image.scaleToFit(12, 12); } cellValues = new String[][] { { "Project - " + basicInfo.getProjectTitle(), funcPerform.getProjectStatus(), funcPerform.getProjectTrend(), funcPerform.getProjectComment() }, { " Target Budget", funcPerform.getTargetBudgetStatus(), funcPerform.getTargetBudgetTrend(), funcPerform.getTargetBudgetComment() }, { " Safety", funcPerform.getSafetyStatus(), funcPerform.getSafetyTrend(), funcPerform.getSafetyComment() }, { " Licensing & Permitting", funcPerform.getLicensingStatus(), funcPerform.getLicensingTrend(), funcPerform.getLicensingComment() }, { " Corporate Properties", funcPerform.getCorporateStatus(), funcPerform.getCorporateTrend(), funcPerform.getCorporateComment() }, { " Inside Plant Design & Engineering", funcPerform.getIPDEStatus(), funcPerform.getIPDETrend(), funcPerform.getIPDEComment() }, { " Public Outreach", funcPerform.getOutreachStatus(), funcPerform.getOutreachTrend(), funcPerform.getOutreachComment() }, { " Procurement", funcPerform.getProcureStatus(), funcPerform.getProcureTrend(), funcPerform.getProcureComment() }, { " Construction", funcPerform.getConstructionStatus(), funcPerform.getConstructionTrend(), funcPerform.getConstructionComment() }, { " Environmental - Resource Recovery", funcPerform.getEnviromentStatus(), funcPerform.getEnviromentTrend(), funcPerform.getEnviromentComment() }, { " Salvage", funcPerform.getSalvageStatus(), funcPerform.getSalvageTrend(), funcPerform.getSalvageComment() }, { " Withdrawal", funcPerform.getWithdrawalStatus(), funcPerform.getWithdrawalTrend(), funcPerform.getWithdrawalComment() } }; for (int i = 0; i < cellValues.length; i++) { cell = new PdfPCell(new Phrase(cellValues[i][0])); cell.setHorizontalAlignment(Element.ALIGN_LEFT); table.addCell(cell); cell = new PdfPCell(new Phrase(cellValues[i][1])); cell.setBackgroundColor(getBackgroundColor(cellValues[i][1])); cell.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(cell); if ("Up".equals(cellValues[i][2])) { cell = new PdfPCell(imgArrowUp); } else if ("Down".equals(cellValues[i][2])) { cell = new PdfPCell(imgArrowDown); } else if ("Even".equals(cellValues[i][2])) { cell = new PdfPCell(imgArrowEven); } else { cell = new PdfPCell(); } cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); cell = new PdfPCell(new Phrase(cellValues[i][3])); cell.setHorizontalAlignment(Element.ALIGN_LEFT); table.addCell(cell); } document.add(table); // *******************************************************************************************// document.setPageSize(DEFAULT_PAGE_SIZE.rotate()); document.add(Chunk.NEXTPAGE); addOutline(outline2, writer, MPSRUI.TREE_1_2_2); addSectionTitle(document, MPSRUI.TREE_1_2_2, fontSection2Header, 12, 12, 12); addImage(document, MPSRUI.getFilePath(mpsrID, costPerform.getFileName())); // *******************************************************************************************// // 1.2.3 Schedule Performance // *******************************************************************************************// document.add(Chunk.NEXTPAGE); addOutline(outline2, writer, MPSRUI.TREE_1_2_3); addSectionTitle(document, MPSRUI.TREE_1_2_3, fontSection2Header, 12, 12, 12); table = new PdfPTable(9); table.setTotalWidth(750); table.setLockedWidth(true); table.setWidths(new int[] { 3, 1, 1, 1, 1, 1, 1, 1, 1 }); table.setHorizontalAlignment(Element.ALIGN_CENTER); headers = new String[] { "WBS", "Original Duration", "Remaining Duration", "Baseline Start Date", "Baseline Finish Date", "Start Date", "Finish Date", "Total Float", "Status" }; for (String header : headers) { cell = new PdfPCell(new Phrase(header, fontTableColumnHeaderYellow)); cell.setBackgroundColor(BaseColor.BLUE); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); } for (int i = 0; i < schedulePerform.length; i++) { cell = new PdfPCell(new Phrase(schedulePerform[i].getWBS())); cell.setHorizontalAlignment(Element.ALIGN_LEFT); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); cell = new PdfPCell(new Phrase(Double.toString(schedulePerform[i].getOriginalDuration()))); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); cell = new PdfPCell(new Phrase(Double.toString(schedulePerform[i].getRemainingDuration()))); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); cell = new PdfPCell(new Phrase(schedulePerform[i].getPlannedStartDate())); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); cell = new PdfPCell(new Phrase(schedulePerform[i].getPlannedFinishDate())); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); cell = new PdfPCell(new Phrase(schedulePerform[i].getStartDate())); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); cell = new PdfPCell(new Phrase(schedulePerform[i].getFinishDate())); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); cell = new PdfPCell(new Phrase(schedulePerform[i].getTotalFloat())); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); cell = new PdfPCell(new Phrase(schedulePerform[i].getStatus())); cell.setHorizontalAlignment(Element.ALIGN_LEFT); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); } table.setHeaderRows(1); document.add(table); // *******************************************************************************************// // 1.3 Project Change Control // *******************************************************************************************// document.setPageSize(DEFAULT_PAGE_SIZE); document.add(Chunk.NEXTPAGE); outline2 = addOutline(outline1, writer, MPSRUI.TREE_1_3); addSectionTitle(document, MPSRUI.TREE_1_3, fontSection1Header, 6, 12, 12); addOutline(outline2, writer, MPSRUI.TREE_1_3_1); addSectionTitle(document, MPSRUI.TREE_1_3_1, fontSection2Header, 12, 12, 0); addParagraph(document, writer, xmlWorker, exeSummary.getDesc_1_3_1(), fontNormal, 12, 0, 12); addOutline(outline2, writer, MPSRUI.TREE_1_3_2); addSectionTitle(document, MPSRUI.TREE_1_3_2, fontSection2Header, 12, 12, 0); addParagraph(document, writer, xmlWorker, exeSummary.getDesc_1_3_2(), fontNormal, 12, 0, 12); // *******************************************************************************************// // 2 Safety // *******************************************************************************************// addOutline(root, writer, MPSRUI.TREE_2); addSectionTitle(document, MPSRUI.TREE_2, fontChapterHeader, 0, 24, 12); addParagraph(document, writer, xmlWorker, safety.getDesc1(), fontNormal, 12, 0, 12); paragraph = new Paragraph("Table 2.1 Project Safety Summary", fontTableCaption); paragraph.setAlignment(Element.ALIGN_CENTER); paragraph.setSpacingAfter(6); document.add(paragraph); table = new PdfPTable(3); table.setTotalWidth(300); table.setLockedWidth(true); table.setWidths(new int[] { 1, 1, 1 }); table.setHorizontalAlignment(Element.ALIGN_RIGHT); cell = new PdfPCell(new Phrase("Total Work Hours", fontTableColumnHeaderYellow)); cell.setColspan(3); cell.setBackgroundColor(BaseColor.BLUE); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); headers = new String[] { "Current Period", "Calendar YTD", "Project To Date" }; for (String header : headers) { cell = new PdfPCell(new Phrase(header, fontTableColumnHeader)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); } cellValues = new String[][] { { INTEGER_FORMATTER.format(safety.getTotalWorkHoursCurrent()), INTEGER_FORMATTER.format(safety.getTotalWorkHoursYTD()), INTEGER_FORMATTER.format(safety.getTotalWorkHoursPTD()) } }; for (int i = 0; i < cellValues.length; i++) { cell = new PdfPCell(new Phrase(cellValues[i][0])); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); cell = new PdfPCell(new Phrase(cellValues[i][1])); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); cell = new PdfPCell(new Phrase(cellValues[i][2], fontTableCellBold)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); } document.add(table); // ----------------------------------- table = new PdfPTable(4); table.setTotalWidth(500); table.setLockedWidth(true); table.setWidths(new int[] { 2, 1, 1, 1 }); table.setHorizontalAlignment(Element.ALIGN_RIGHT); cell = new PdfPCell(new Phrase("Incidents", fontTableColumnHeaderYellow)); cell.setColspan(4); cell.setBackgroundColor(BaseColor.BLUE); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); cellValues = new String[][] { { "OSHA Recordable", INTEGER_FORMATTER.format(safety.getOshaRecordableCurrent()), INTEGER_FORMATTER.format(safety.getOshaRecordableYTD()), INTEGER_FORMATTER.format(safety.getOshaRecordablePTD()) }, { "First Aid", INTEGER_FORMATTER.format(safety.getFirstAid1Current()), INTEGER_FORMATTER.format(safety.getFirstAid1YTD()), INTEGER_FORMATTER.format(safety.getFirstAid1PTD()) }, { "Near Miss", INTEGER_FORMATTER.format(safety.getNearMissCurrent()), INTEGER_FORMATTER.format(safety.getNearMissYTD()), INTEGER_FORMATTER.format(safety.getNearMissPTD()) }, { "First Aid", INTEGER_FORMATTER.format(safety.getFirstAid2Current()), INTEGER_FORMATTER.format(safety.getFirstAid2YTD()), INTEGER_FORMATTER.format(safety.getFirstAid2PTD()) } }; for (int i = 0; i < cellValues.length; i++) { cell = new PdfPCell(new Phrase(cellValues[i][0], fontTableRowTitle)); cell.setHorizontalAlignment(Element.ALIGN_LEFT); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); cell = new PdfPCell(new Phrase(cellValues[i][1])); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); cell = new PdfPCell(new Phrase(cellValues[i][2])); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); cell = new PdfPCell(new Phrase(cellValues[i][3], fontTableCellBold)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); } cell = new PdfPCell(new Phrase("*Note - " + safety.getNote(), fontTableNote)); cell.setColspan(4); cell.setHorizontalAlignment(Element.ALIGN_LEFT); cell.setVerticalAlignment(Element.ALIGN_TOP); table.addCell(cell); document.add(table); // *******************************************************************************************// // 3 Project Authorization // *******************************************************************************************// addOutline(root, writer, MPSRUI.TREE_3); addSectionTitle(document, MPSRUI.TREE_3, fontChapterHeader, 0, 24, 12); addParagraph(document, writer, xmlWorker, auth.getDesc1(), fontNormal, 12, 0, 12); table = new PdfPTable(10); table.setSpacingBefore(6); table.setTotalWidth(550); table.setLockedWidth(true); table.setWidths(new int[] { 3, 1, 1, 1, 1, 1, 1, 2, 1, 1 }); table.setHorizontalAlignment(Element.ALIGN_CENTER); headers = new String[] { "$ Millions", "Prior", auth.getHeaderYear0(), auth.getHeaderYear1(), auth.getHeaderYear2(), auth.getHeaderYear3(), auth.getHeaderYear4(), auth.getHeaderPostYear(), "Total", "Auth" }; for (String header : headers) { cell = new PdfPCell(new Phrase(header, fontTableColumnHeader)); cell.setBackgroundColor(BaseColor.YELLOW); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); } cellValues = new String[][] { { "Base", NUMBER_FORMATTER.format(auth.getBasePriorYear()), NUMBER_FORMATTER.format(auth.getBaseYear0()), NUMBER_FORMATTER.format(auth.getBaseYear1()), NUMBER_FORMATTER.format(auth.getBaseYear2()), NUMBER_FORMATTER.format(auth.getBaseYear3()), NUMBER_FORMATTER.format(auth.getBaseYear4()), NUMBER_FORMATTER.format(auth.getBasePostYear()), NUMBER_FORMATTER.format(auth.getBaseTotal()), "" }, { "Risk & Contingency", NUMBER_FORMATTER.format(auth.getRnCPriorYear()), NUMBER_FORMATTER.format(auth.getRnCYear0()), NUMBER_FORMATTER.format(auth.getRnCYear1()), NUMBER_FORMATTER.format(auth.getRnCYear2()), NUMBER_FORMATTER.format(auth.getRnCYear3()), NUMBER_FORMATTER.format(auth.getRnCYear4()), NUMBER_FORMATTER.format(auth.getRnCPostYear()), NUMBER_FORMATTER.format(auth.getRnCTotal()), "" }, { "Total Project " + auth.getTotalProjectDate(), NUMBER_FORMATTER.format(auth.getPriorTotal()), NUMBER_FORMATTER.format(auth.getYear0Total()), NUMBER_FORMATTER.format(auth.getYear1Total()), NUMBER_FORMATTER.format(auth.getYear2Total()), NUMBER_FORMATTER.format(auth.getYear3Total()), NUMBER_FORMATTER.format(auth.getYear4Total()), NUMBER_FORMATTER.format(auth.getPostTotal()), NUMBER_FORMATTER.format(auth.getTotalTotal()), "" }, { "Current Request " + auth.getReq0RequestDate(), NUMBER_FORMATTER.format(auth.getReq0PriorYear()), NUMBER_FORMATTER.format(auth.getReq0Year0()), NUMBER_FORMATTER.format(auth.getReq0Year1()), NUMBER_FORMATTER.format(auth.getReq0Year2()), NUMBER_FORMATTER.format(auth.getReq0Year3()), NUMBER_FORMATTER.format(auth.getReq0Year4()), NUMBER_FORMATTER.format(auth.getReq0PostYear()), NUMBER_FORMATTER.format(auth.getReq0Total()), NUMBER_FORMATTER.format(auth.getReq0Authorization()) }, { "Request Date " + auth.getReq1RequestDate(), NUMBER_FORMATTER.format(auth.getReq1PriorYear()), NUMBER_FORMATTER.format(auth.getReq1Year0()), NUMBER_FORMATTER.format(auth.getReq1Year1()), NUMBER_FORMATTER.format(auth.getReq1Year2()), NUMBER_FORMATTER.format(auth.getReq1Year3()), NUMBER_FORMATTER.format(auth.getReq1Year4()), NUMBER_FORMATTER.format(auth.getReq1PostYear()), NUMBER_FORMATTER.format(auth.getReq1Total()), NUMBER_FORMATTER.format(auth.getReq1Authorization()) }, { "Request Date " + auth.getReq2RequestDate(), NUMBER_FORMATTER.format(auth.getReq2PriorYear()), NUMBER_FORMATTER.format(auth.getReq2Year0()), NUMBER_FORMATTER.format(auth.getReq2Year1()), NUMBER_FORMATTER.format(auth.getReq2Year2()), NUMBER_FORMATTER.format(auth.getReq2Year3()), NUMBER_FORMATTER.format(auth.getReq2Year4()), NUMBER_FORMATTER.format(auth.getReq2PostYear()), NUMBER_FORMATTER.format(auth.getReq2Total()), NUMBER_FORMATTER.format(auth.getReq2Authorization()) }, { "Target Budget", "", "", "", "", "", "", "", auth.getTargetBudget(), "" } }; for (int i = 0; i < cellValues.length; i++) { cell = new PdfPCell(new Phrase(cellValues[i][0])); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); for (int j = 1; j < cellValues[i].length; j++) { cell = new PdfPCell(new Phrase(cellValues[i][j])); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); } } document.add(table); // *******************************************************************************************// // 4 Project Budget // *******************************************************************************************// addOutline(root, writer, MPSRUI.TREE_4); addSectionTitle(document, MPSRUI.TREE_4, fontChapterHeader, 0, 24, 12); addParagraph(document, writer, xmlWorker, budget.getDesc1(), fontNormal, 12, 0, 12); table = new PdfPTable(2); table.setSpacingBefore(6); table.setTotalWidth(350); table.setLockedWidth(true); table.setWidths(new int[] { 5, 2 }); table.setHorizontalAlignment(Element.ALIGN_CENTER); cellValues = new String[][] { { "Current Approved Budget (Base + RnC)", CURRENCY_FORMATTER.format(budget.getPMBudget()) + "M" }, { "Approved Phase Funding", CURRENCY_FORMATTER.format(budget.getPMActual()) + "M" }, { "Expended To Date", CURRENCY_FORMATTER.format(budget.getPMCommitment()) + "M" }, { "At Completion", CURRENCY_FORMATTER.format(budget.getPMAdditionalCost()) + "M" } }; for (int i = 0; i < cellValues.length; i++) { cell = new PdfPCell(new Phrase(cellValues[i][0])); cell.setHorizontalAlignment(Element.ALIGN_LEFT); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); cell = new PdfPCell(new Phrase(cellValues[i][1])); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); } document.add(table); // ---------------------------------------------------- // table 4.1 // ---------------------------------------------------- paragraph = new Paragraph("Table 4.1 Cost Report Summary", fontTableCaption); paragraph.setAlignment(Element.ALIGN_CENTER); paragraph.setSpacingAfter(6); document.add(paragraph); table = new PdfPTable(5); table.setTotalWidth(500); table.setLockedWidth(true); table.setWidths(new int[] { 1, 1, 1, 1, 1 }); table.setHorizontalAlignment(Element.ALIGN_CENTER); headers = new String[] { "Work Element", "Description", "Estimate", "Actual", "EAC" }; for (String header : headers) { cell = new PdfPCell(new Phrase(header, fontTableColumnHeaderYellow)); cell.setBackgroundColor(BaseColor.BLUE); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); } for (int i = 0; i < costRpt.length; i++) { cell = new PdfPCell(new Phrase(costRpt[i].getWbs())); cell.setHorizontalAlignment(Element.ALIGN_LEFT); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); cell = new PdfPCell(new Phrase(costRpt[i].getWbsDesc())); cell.setHorizontalAlignment(Element.ALIGN_LEFT); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); cell = new PdfPCell(new Phrase(formatNumberString(costRpt[i].getEstimate()))); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); cell = new PdfPCell(new Phrase(formatNumberString(costRpt[i].getActual()))); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); cell = new PdfPCell(new Phrase(formatNumberString(costRpt[i].getEAC()))); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); } document.add(table); // *******************************************************************************************// // 5 Project Schedule // *******************************************************************************************// outline1 = addOutline(root, writer, MPSRUI.TREE_5); addSectionTitle(document, MPSRUI.TREE_5, fontChapterHeader, 0, 24, 12); addOutline(outline1, writer, MPSRUI.TREE_5_1); addSectionTitle(document, MPSRUI.TREE_5_1, fontSection1Header, 6, 12, 12); addParagraph(document, writer, xmlWorker, schedule.getDesc_5_1(), fontNormal, 12, 0, 12); addOutline(outline1, writer, MPSRUI.TREE_5_2); addSectionTitle(document, MPSRUI.TREE_5_2, fontSection1Header, 6, 12, 12); addParagraph(document, writer, xmlWorker, schedule.getDesc_5_2(), fontNormal, 12, 0, 12); addOutline(outline1, writer, MPSRUI.TREE_5_3); addSectionTitle(document, MPSRUI.TREE_5_3, fontSection1Header, 6, 12, 12); addParagraph(document, writer, xmlWorker, schedule.getDesc_5_3(), fontNormal, 12, 0, 12); addOutline(outline1, writer, MPSRUI.TREE_5_4); addSectionTitle(document, MPSRUI.TREE_5_4, fontSection1Header, 6, 12, 12); addParagraph(document, writer, xmlWorker, schedule.getDesc_5_4(), fontNormal, 12, 0, 12); // ---------------------------------------------------- // table 5.1 // ---------------------------------------------------- paragraph = new Paragraph("Table 5.1 Planned Scorecard Milestones", fontTableCaption); paragraph.setAlignment(Element.ALIGN_CENTER); paragraph.setSpacingAfter(6); document.add(paragraph); table = new PdfPTable(3); table.setTotalWidth(500); table.setLockedWidth(true); table.setWidths(new int[] { 3, 1, 1 }); table.setHorizontalAlignment(Element.ALIGN_CENTER); headers = new String[] { "Milestone", "Planned Date", "Finish Date" }; for (String header : headers) { cell = new PdfPCell(new Phrase(header, fontTableColumnHeaderYellow)); cell.setBackgroundColor(BaseColor.BLUE); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); } for (int i = 0; i < milestones.length; i++) { cell = new PdfPCell(new Phrase(milestones[i].getMilestone())); cell.setHorizontalAlignment(Element.ALIGN_LEFT); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); cell = new PdfPCell(new Phrase(milestones[i].getPlannedDate())); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); cell = new PdfPCell(new Phrase(milestones[i].getFinishDate())); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); } document.add(table); // *******************************************************************************************// // 6 License & Permitting, and Environmental Status // *******************************************************************************************// outline1 = addOutline(root, writer, MPSRUI.TREE_6); addSectionTitle(document, MPSRUI.TREE_6, fontChapterHeader, 0, 24, 12); addOutline(outline1, writer, MPSRUI.TREE_6_1); addSectionTitle(document, MPSRUI.TREE_6_1, fontSection1Header, 6, 12, 12); addParagraph(document, writer, xmlWorker, lpe.getDesc_6_1(), fontNormal, 12, 0, 12); outline2 = addOutline(outline1, writer, MPSRUI.TREE_6_2); addSectionTitle(document, MPSRUI.TREE_6_2, fontSection1Header, 6, 12, 12); addOutline(outline2, writer, MPSRUI.TREE_6_2_1); addSectionTitle(document, MPSRUI.TREE_6_2_1, fontSection2Header, 12, 12, 12); addParagraph(document, writer, xmlWorker, lpe.getDesc_6_2_1(), fontNormal, 12, 0, 12); addOutline(outline2, writer, MPSRUI.TREE_6_2_2); addSectionTitle(document, MPSRUI.TREE_6_2_2, fontSection2Header, 12, 12, 12); addParagraph(document, writer, xmlWorker, lpe.getDesc_6_2_2(), fontNormal, 12, 0, 12); // *******************************************************************************************// // 7 Engineering Status // *******************************************************************************************// outline1 = addOutline(root, writer, MPSRUI.TREE_7); addSectionTitle(document, MPSRUI.TREE_7, fontChapterHeader, 0, 24, 12); addOutline(outline1, writer, MPSRUI.TREE_7_1); addSectionTitle(document, MPSRUI.TREE_7_1, fontSection1Header, 6, 12, 12); table = new PdfPTable(5); table.setTotalWidth(500); table.setLockedWidth(true); table.setWidths(new int[] { 2, 1, 1, 1, 3 }); table.setHorizontalAlignment(Element.ALIGN_CENTER); headers = new String[] { "Package", "IFR", "IFC", "Indicator", "Note" }; for (String header : headers) { cell = new PdfPCell(new Phrase(header, fontTableColumnHeaderYellow)); cell.setBackgroundColor(BaseColor.BLUE); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); } for (int i = 0; i < ipds.length; i++) { cell = new PdfPCell(new Phrase(ipds[i].getPackage())); cell.setHorizontalAlignment(Element.ALIGN_LEFT); cell.setVerticalAlignment(Element.ALIGN_TOP); table.addCell(cell); cell = new PdfPCell(new Phrase(ipds[i].getIFR())); cell.setHorizontalAlignment(Element.ALIGN_LEFT); cell.setVerticalAlignment(Element.ALIGN_TOP); table.addCell(cell); cell = new PdfPCell(new Phrase(ipds[i].getIFC())); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); cell.setVerticalAlignment(Element.ALIGN_TOP); table.addCell(cell); cell = new PdfPCell(new Phrase(ipds[i].getIndicator())); cell.setBackgroundColor(getBackgroundColor(ipds[i].getIndicator())); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_TOP); table.addCell(cell); cell = new PdfPCell(new Phrase(ipds[i].getNote())); cell.setHorizontalAlignment(Element.ALIGN_LEFT); cell.setVerticalAlignment(Element.ALIGN_TOP); table.addCell(cell); } document.add(table); // -----------------------------------------------------------------------------------// addOutline(outline1, writer, MPSRUI.TREE_7_2); addSectionTitle(document, MPSRUI.TREE_7_2, fontSection1Header, 6, 12, 12); table = new PdfPTable(5); table.setTotalWidth(500); table.setLockedWidth(true); table.setWidths(new int[] { 2, 1, 1, 1, 3 }); table.setHorizontalAlignment(Element.ALIGN_CENTER); headers = new String[] { "Package", "IFR", "IFC", "Indicator", "Note" }; for (String header : headers) { cell = new PdfPCell(new Phrase(header, fontTableColumnHeaderYellow)); cell.setBackgroundColor(BaseColor.BLUE); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); } for (int i = 0; i < opds.length; i++) { cell = new PdfPCell(new Phrase(opds[i].getPackage())); cell.setHorizontalAlignment(Element.ALIGN_LEFT); cell.setVerticalAlignment(Element.ALIGN_TOP); table.addCell(cell); cell = new PdfPCell(new Phrase(opds[i].getIFR())); cell.setHorizontalAlignment(Element.ALIGN_LEFT); cell.setVerticalAlignment(Element.ALIGN_TOP); table.addCell(cell); cell = new PdfPCell(new Phrase(opds[i].getIFC())); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); cell.setVerticalAlignment(Element.ALIGN_TOP); table.addCell(cell); cell = new PdfPCell(new Phrase(opds[i].getIndicator())); cell.setBackgroundColor(getBackgroundColor(opds[i].getIndicator())); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_TOP); table.addCell(cell); cell = new PdfPCell(new Phrase(opds[i].getNote())); cell.setHorizontalAlignment(Element.ALIGN_LEFT); cell.setVerticalAlignment(Element.ALIGN_TOP); table.addCell(cell); } document.add(table); // *******************************************************************************************// // 8 Procurement Status // *******************************************************************************************// outline1 = addOutline(root, writer, MPSRUI.TREE_8); addSectionTitle(document, MPSRUI.TREE_8, fontChapterHeader, 0, 24, 12); outline2 = addOutline(outline1, writer, MPSRUI.TREE_8_1); addSectionTitle(document, MPSRUI.TREE_8_1, fontSection1Header, 6, 12, 12); table = new PdfPTable(2); table.setTotalWidth(300); table.setLockedWidth(true); table.setWidths(new int[] { 1, 1 }); table.setHorizontalAlignment(Element.ALIGN_CENTER); cellValues = new String[][] { { "Receipted to Date", CURRENCY_FORMATTER.format(procure.getReceiptedToDate()) }, { "Open Commitments", CURRENCY_FORMATTER.format(procure.getOpenCommitment()) }, { "Total", CURRENCY_FORMATTER.format(procure.getTotalPurchaseOrder()) } }; for (int i = 0; i < cellValues.length; i++) { cell = new PdfPCell(new Phrase(cellValues[i][0])); cell.setHorizontalAlignment(Element.ALIGN_LEFT); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); cell = new PdfPCell(new Phrase(cellValues[i][1])); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); } document.add(table); addParagraph(document, writer, xmlWorker, procure.getDesc_8_1_B(), fontNormal, 12, 12, 12); outline2 = addOutline(outline1, writer, MPSRUI.TREE_8_2); addSectionTitle(document, MPSRUI.TREE_8_2, fontSection1Header, 6, 12, 12); // ---------------------------------------------------- // section 8.2.1 // ---------------------------------------------------- addOutline(outline2, writer, MPSRUI.TREE_8_2_1); addSectionTitle(document, MPSRUI.TREE_8_2_1, fontSection2Header, 12, 12, 12); addParagraph(document, writer, xmlWorker, procure.getDesc_8_2_1(), fontNormal, 12, 0, 12); table = new PdfPTable(6); table.setTotalWidth(550); table.setLockedWidth(true); table.setWidths(new int[] { 1, 2, 1, 1, 2, 1 }); table.setHorizontalAlignment(Element.ALIGN_CENTER); headers = new String[] { "Purchase Order", "Vendor", "Previous Amount", "This Month Amount", "This Month Description", "Total Amount" }; for (String header : headers) { cell = new PdfPCell(new Phrase(header, fontPOTableHeader)); cell.setBackgroundColor(BaseColor.BLUE); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); } double totalToDate = 0; for (int i = 0; i < approvedChanges.length; i++) { cell = new PdfPCell(new Phrase(approvedChanges[i].getPurchaseOrder(), fontPOTable)); cell.setHorizontalAlignment(Element.ALIGN_LEFT); cell.setVerticalAlignment(Element.ALIGN_TOP); table.addCell(cell); cell = new PdfPCell(new Phrase(approvedChanges[i].getVendor(), fontPOTable)); cell.setHorizontalAlignment(Element.ALIGN_LEFT); cell.setVerticalAlignment(Element.ALIGN_TOP); table.addCell(cell); cell = new PdfPCell( new Phrase(CURRENCY_FORMATTER.format(approvedChanges[i].getPreviousAmount()), fontPOTable)); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); cell.setVerticalAlignment(Element.ALIGN_TOP); table.addCell(cell); cell = new PdfPCell(new Phrase(CURRENCY_FORMATTER.format(approvedChanges[i].getThisMonthAmount()), fontPOTable)); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); cell.setVerticalAlignment(Element.ALIGN_TOP); table.addCell(cell); cell = new PdfPCell(new Phrase(approvedChanges[i].getThisMonthDescription(), fontPOTable)); cell.setHorizontalAlignment(Element.ALIGN_LEFT); cell.setVerticalAlignment(Element.ALIGN_TOP); table.addCell(cell); cell = new PdfPCell( new Phrase(CURRENCY_FORMATTER.format(approvedChanges[i].getTotalAmount()), fontPOTable)); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); cell.setVerticalAlignment(Element.ALIGN_TOP); table.addCell(cell); totalToDate += approvedChanges[i].getTotalAmount(); } document.add(table); table = new PdfPTable(2); table.setTotalWidth(550); table.setLockedWidth(true); table.setWidths(new int[] { 7, 1 }); table.setHorizontalAlignment(Element.ALIGN_CENTER); cell = new PdfPCell(new Phrase("Total To Date", fontPOTableSummary)); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); cell.setVerticalAlignment(Element.ALIGN_TOP); table.addCell(cell); cell = new PdfPCell(new Phrase(CURRENCY_FORMATTER.format(totalToDate), fontPOTableSummary)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_TOP); table.addCell(cell); document.add(table); // ---------------------------------------------------- // section 8.2.2 // ---------------------------------------------------- addOutline(outline2, writer, MPSRUI.TREE_8_2_2); addSectionTitle(document, MPSRUI.TREE_8_2_2, fontSection2Header, 12, 12, 12); addParagraph(document, writer, xmlWorker, procure.getDesc_8_2_2(), fontNormal, 12, 0, 12); table = new PdfPTable(6); table.setTotalWidth(550); table.setLockedWidth(true); table.setWidths(new int[] { 1, 2, 1, 1, 2, 1 }); table.setHorizontalAlignment(Element.ALIGN_CENTER); headers = new String[] { "Purchase Order", "Vendor", "Previous Amount", "This Month Amount", "This Month Description", "Total Amount" }; for (String header : headers) { cell = new PdfPCell(new Phrase(header, fontPOTableHeader)); cell.setBackgroundColor(BaseColor.BLUE); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); } totalToDate = 0; for (int i = 0; i < pendingChanges.length; i++) { cell = new PdfPCell(new Phrase(pendingChanges[i].getPurchaseOrder(), fontPOTable)); cell.setHorizontalAlignment(Element.ALIGN_LEFT); cell.setVerticalAlignment(Element.ALIGN_TOP); table.addCell(cell); cell = new PdfPCell(new Phrase(pendingChanges[i].getVendor(), fontPOTable)); cell.setHorizontalAlignment(Element.ALIGN_LEFT); cell.setVerticalAlignment(Element.ALIGN_TOP); table.addCell(cell); cell = new PdfPCell( new Phrase(CURRENCY_FORMATTER.format(pendingChanges[i].getPreviousAmount()), fontPOTable)); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); cell.setVerticalAlignment(Element.ALIGN_TOP); table.addCell(cell); cell = new PdfPCell( new Phrase(CURRENCY_FORMATTER.format(pendingChanges[i].getThisMonthAmount()), fontPOTable)); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); cell.setVerticalAlignment(Element.ALIGN_TOP); table.addCell(cell); cell = new PdfPCell(new Phrase(pendingChanges[i].getThisMonthDescription(), fontPOTable)); cell.setHorizontalAlignment(Element.ALIGN_LEFT); cell.setVerticalAlignment(Element.ALIGN_TOP); table.addCell(cell); cell = new PdfPCell( new Phrase(CURRENCY_FORMATTER.format(pendingChanges[i].getTotalAmount()), fontPOTable)); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); cell.setVerticalAlignment(Element.ALIGN_TOP); table.addCell(cell); totalToDate += pendingChanges[i].getTotalAmount(); } document.add(table); table = new PdfPTable(2); table.setTotalWidth(550); table.setLockedWidth(true); table.setWidths(new int[] { 7, 1 }); table.setHorizontalAlignment(Element.ALIGN_CENTER); cell = new PdfPCell(new Phrase("Total To Date", fontPOTableSummary)); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); cell.setVerticalAlignment(Element.ALIGN_TOP); table.addCell(cell); cell = new PdfPCell(new Phrase(CURRENCY_FORMATTER.format(totalToDate), fontPOTableSummary)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_TOP); table.addCell(cell); document.add(table); // *******************************************************************************************// // 9 Construction Status // *******************************************************************************************// outline1 = addOutline(root, writer, MPSRUI.TREE_9); addSectionTitle(document, MPSRUI.TREE_9, fontChapterHeader, 0, 24, 12); addOutline(outline1, writer, MPSRUI.TREE_9_1); addSectionTitle(document, MPSRUI.TREE_9_1, fontSection1Header, 6, 12, 12); for (int i = 0; i < ipcs.length; i++) { addParagraph(document, writer, xmlWorker, ipcs[i].getWork(), fontWork, 12, 12, 0); addParagraph(document, writer, xmlWorker, ipcs[i].getDescription(), fontNormal, 12, 0, 0); addImage(document, MPSRUI.getFilePath(mpsrID, ipcs[i].getFileName()), "Figure " + ipcs[i].getFigure() + " " + ipcs[i].getTitle(), fontImageCaption, 12, 3, 12); } // -----------------------------------------------------------------------------------------// addOutline(outline1, writer, MPSRUI.TREE_9_2); addSectionTitle(document, MPSRUI.TREE_9_2, fontSection1Header, 6, 12, 12); for (int i = 0; i < opcs.length; i++) { addParagraph(document, writer, xmlWorker, opcs[i].getWork(), fontWork, 12, 12, 0); addParagraph(document, writer, xmlWorker, opcs[i].getDescription(), fontNormal, 12, 0, 0); addImage(document, MPSRUI.getFilePath(mpsrID, opcs[i].getFileName()), "Figure " + opcs[i].getFigure() + " " + opcs[i].getTitle(), fontImageCaption, 12, 3, 12); } // *******************************************************************************************// // Appendix // *******************************************************************************************// if (appendixs.length > 0) { document.add(Chunk.NEXTPAGE); outline1 = addOutline(root, writer, MPSRUI.TREE_APPENDIX); for (int i = 0; i < appendixs.length; i++) { addOutline(outline1, writer, "Appendix " + appendixs[i].getNumber() + " " + appendixs[i].getTitle()); addSectionTitle(document, "Appendix " + appendixs[i].getNumber() + " " + appendixs[i].getTitle(), fontChapterHeader, 0, 12, 12); addParagraph(document, writer, xmlWorker, appendixs[i].getDescription(), fontNormal, 12, 0, 0); importPages(document, writer, mpsrID, appendixs[i].getFileName()); } } // *******************************************************************************************// // Attachment // *******************************************************************************************// if (attachments.length > 0) { document.setPageSize(DEFAULT_PAGE_SIZE); document.add(Chunk.NEXTPAGE); outline1 = addOutline(root, writer, MPSRUI.TREE_ATTACHMENT); for (int i = 0; i < attachments.length; i++) { addOutline(outline1, writer, "Attachment " + attachments[i].getNumber() + " " + attachments[i].getTitle()); addSectionTitle(document, "Attachment " + attachments[i].getNumber() + " " + attachments[i].getTitle(), fontChapterHeader, 0, 12, 12); addParagraph(document, writer, xmlWorker, attachments[i].getDescription(), fontNormal, 12, 0, 0); importPages(document, writer, mpsrID, attachments[i].getFileName()); } } document.close(); // *******************************************************************************************// // retrieve outline PdfReader readerOrig = new PdfReader(baosOrig.toByteArray()); // int origNumberOfPages = readerOrig.getNumberOfPages(); ColumnText ct = new ColumnText(null); ct.addElement(new Paragraph("Table of Contents", fontCoverTitle)); List<HashMap<String, Object>> bookmarkList = SimpleBookmark.getBookmark(readerOrig); fillColumnText(bookmarkList, ct, 18, 0, fontSection2Header); // generate TOC after cover page ByteArrayOutputStream baosTOC = new ByteArrayOutputStream(); PdfStamper stamperTOC = new PdfStamper(readerOrig, baosTOC); int tocPageEnd = 1; while (true) { stamperTOC.insertPage(++tocPageEnd, readerOrig.getPageSize(1)); PdfContentByte underContent = stamperTOC.getUnderContent(tocPageEnd); generatePageHeader(document, underContent, icon, headerTexts); ct.setCanvas(stamperTOC.getOverContent(tocPageEnd)); ct.setSimpleColumn(36, 36, 558, 693); if (!ColumnText.hasMoreText(ct.go())) break; } stamperTOC.close(); // change page labels PdfPageLabels labels = new PdfPageLabels(); labels.addPageLabel(1, PdfPageLabels.LOWERCASE_ROMAN_NUMERALS); labels.addPageLabel(tocPageEnd + 1, PdfPageLabels.DECIMAL_ARABIC_NUMERALS); // add labels ByteArrayOutputStream baosFinal = new ByteArrayOutputStream(); PdfReader readerTOC = new PdfReader(baosTOC.toByteArray()); // String selectPages = String.format("1-%s,%s-%s", tocPageEnd, // tocPageEnd + 1, origNumberOfPages + (tocPageEnd - 1)); // readerTOC.selectPages(selectPages); PdfStamper stamperFinal = new PdfStamper(readerTOC, baosFinal); stamperFinal.getWriter().setPageLabels(labels); stamperFinal.close(); // *******************************************************************************************// // send final PDF to browser response.setHeader("Expires", "0"); response.setHeader("Cache-Control", "must-revalidate, post-check=0, pre-check=0"); response.setHeader("Pragma", "public"); response.setContentType("application/pdf"); response.setContentLength(baosFinal.size()); OutputStream os = response.getOutputStream(); os.write(baosFinal.toByteArray()); os.flush(); os.close(); } catch (DocumentException e) { e.printStackTrace(); } }
From source file:com.quix.aia.cn.imo.mapper.ApplicationFormPDFMaintenance.java
License:Open Source License
private static Document ESingnature(Document document, PdfWriter writer, AddressBook addressbook) { // TODO Auto-generated method stub log.log(Level.INFO, "ApplicationFormPDFMaintenance --> ESingnature "); try {/*from w ww . ja va 2s .c om*/ document.newPage(); PdfPTable table = new PdfPTable(2); table.setSpacingBefore(10); table.setWidthPercentage(100f); PdfPCell c1 = new PdfPCell(new Phrase("E-singnature ")); c1.setHorizontalAlignment(Element.ALIGN_LEFT); c1.setColspan(4); c1.setBorder(Rectangle.LEFT | Rectangle.RIGHT | Rectangle.TOP); c1.setFixedHeight(30f); c1.setBackgroundColor(BaseColor.LIGHT_GRAY); c1.setBorder(Rectangle.BOX); c1.setFixedHeight(25f); table.addCell(c1); table.setHeaderRows(1); for (int i = 0; i < 2; i++) { c1 = new PdfPCell(new Phrase(" ", font)); c1.setBorder(Rectangle.NO_BORDER); c1.setLeading(4f, 0f); c1.setFixedHeight(15f); table.addCell(c1); } Iterator itr = null; CandidateESignature esignature = new CandidateESignature(); if (addressbook.getCandidateESignatures().size() > 0) { itr = addressbook.getCandidateESignatures().iterator(); esignature = (CandidateESignature) itr.next(); } c1 = new PdfPCell(new Phrase("Branch : " + esignature.getBranch(), font)); c1.setBorder(Rectangle.NO_BORDER); c1.setLeading(4f, 0f); c1.setFixedHeight(15f); c1.setBorder(Rectangle.BOTTOM); table.addCell(c1); c1 = new PdfPCell(new Phrase("Servicing Department : " + esignature.getServiceDepartment(), font)); c1.setBorder(Rectangle.NO_BORDER); c1.setLeading(4f, 0f); c1.setFixedHeight(15f); c1.setBorder(Rectangle.BOTTOM); table.addCell(c1); for (int i = 0; i < 2; i++) { c1 = new PdfPCell(new Phrase(" ", font)); c1.setBorder(Rectangle.NO_BORDER); c1.setLeading(4f, 0f); c1.setFixedHeight(15f); table.addCell(c1); } c1 = new PdfPCell(new Phrase("City : " + esignature.getCity(), font)); c1.setBorder(Rectangle.NO_BORDER); c1.setLeading(4f, 0f); c1.setFixedHeight(15f); c1.setBorder(Rectangle.BOTTOM); table.addCell(c1); c1 = new PdfPCell(new Phrase("Agent Code : " + esignature.getAgentId(), font)); c1.setBorder(Rectangle.NO_BORDER); c1.setLeading(4f, 0f); c1.setFixedHeight(15f); c1.setBorder(Rectangle.BOTTOM); table.addCell(c1); for (int i = 0; i < 4; i++) { c1 = new PdfPCell(new Phrase(" ", font)); c1.setBorder(Rectangle.NO_BORDER); c1.setLeading(4f, 0f); c1.setFixedHeight(15f); table.addCell(c1); } document.add(table); table = new PdfPTable(2); table.setSpacingBefore(10); table.setWidthPercentage(100f); table.setWidths(new int[] { 80, 20 }); c1 = new PdfPCell(new Phrase("Presently attached with another insurance Company ? ", font)); c1.setBorder(Rectangle.NO_BORDER); c1.setLeading(4f, 0f); c1.setFixedHeight(15f); table.addCell(c1); c1 = new PdfPCell(new Phrase("Yes \t\t\t\t\t\t\t\t No", font)); c1.setBorder(Rectangle.NO_BORDER); c1.setLeading(4f, 0f); c1.setFixedHeight(15f); table.addCell(c1); for (int i = 0; i < 2; i++) { c1 = new PdfPCell(new Phrase(" ", font)); c1.setBorder(Rectangle.NO_BORDER); c1.setLeading(4f, 0f); c1.setFixedHeight(15f); table.addCell(c1); } c1 = new PdfPCell( new Phrase("Presently in contact with any other AIA'S servicing Department ? ", font)); c1.setBorder(Rectangle.NO_BORDER); c1.setLeading(4f, 0f); c1.setFixedHeight(15f); table.addCell(c1); c1 = new PdfPCell(new Phrase("Yes \t\t\t\t\t\t\t\t No", font)); c1.setBorder(Rectangle.NO_BORDER); c1.setLeading(4f, 0f); c1.setFixedHeight(15f); table.addCell(c1); for (int i = 0; i < 2; i++) { c1 = new PdfPCell(new Phrase(" ", font)); c1.setBorder(Rectangle.NO_BORDER); c1.setLeading(4f, 0f); c1.setFixedHeight(15f); table.addCell(c1); } c1 = new PdfPCell( new Phrase("Taken LOMBRA occupational test or PSP test in the past ? If Yes, ", font)); c1.setBorder(Rectangle.NO_BORDER); c1.setLeading(4f, 0f); c1.setFixedHeight(15f); table.addCell(c1); c1 = new PdfPCell(new Phrase("Yes \t\t\t\t\t\t\t\t No", font)); c1.setBorder(Rectangle.NO_BORDER); c1.setLeading(4f, 0f); c1.setFixedHeight(15f); table.addCell(c1); for (int i = 0; i < 2; i++) { c1 = new PdfPCell(new Phrase(" ", font)); c1.setBorder(Rectangle.NO_BORDER); c1.setLeading(4f, 0f); c1.setFixedHeight(15f); table.addCell(c1); } c1 = new PdfPCell(new Phrase("Please provide the result. ", font)); c1.setBorder(Rectangle.NO_BORDER); c1.setLeading(4f, 0f); c1.setFixedHeight(15f); table.addCell(c1); for (int i = 0; i < 5; i++) { c1 = new PdfPCell(new Phrase(" ", font)); c1.setBorder(Rectangle.NO_BORDER); c1.setLeading(4f, 0f); c1.setFixedHeight(15f); table.addCell(c1); } document.add(table); Paragraph para1 = new Paragraph(); para1.add(new Chunk("Applicant's Declaration ", font)); para1.setAlignment(Element.ALIGN_LEFT); para1.setSpacingAfter(5f); document.add(para1); table = new PdfPTable(2); table.setSpacingBefore(10); table.setWidthPercentage(100f); for (int i = 0; i < 4; i++) { c1 = new PdfPCell(new Phrase(" ", font)); c1.setBorder(Rectangle.NO_BORDER); c1.setLeading(4f, 0f); c1.setFixedHeight(15f); table.addCell(c1); c1 = new PdfPCell(new Phrase(" ", font)); c1.setBorder(Rectangle.NO_BORDER); c1.setLeading(4f, 0f); c1.setFixedHeight(15f); table.addCell(c1); } c1 = new PdfPCell(new Phrase("Application Date", font)); c1.setBorder(Rectangle.NO_BORDER); c1.setLeading(4f, 0f); c1.setFixedHeight(15f); table.addCell(c1); c1 = new PdfPCell(new Phrase("Applicant/Candidate Name :", font)); c1.setBorder(Rectangle.NO_BORDER); c1.setLeading(4f, 0f); c1.setFixedHeight(15f); table.addCell(c1); if (esignature.getApplicationDate() != null) { c1 = new PdfPCell(new Phrase(format.format(esignature.getApplicationDate()), font)); c1.setBorder(Rectangle.NO_BORDER); c1.setLeading(4f, 0f); c1.setFixedHeight(15f); table.addCell(c1); } else { c1 = new PdfPCell(new Phrase("", font)); c1.setBorder(Rectangle.NO_BORDER); c1.setLeading(4f, 0f); c1.setFixedHeight(15f); table.addCell(c1); } c1 = new PdfPCell(new Phrase(esignature.getCandidateName(), font)); c1.setBorder(Rectangle.NO_BORDER); c1.setLeading(4f, 0f); c1.setFixedHeight(15f); table.addCell(c1); for (int i = 0; i < 4; i++) { c1 = new PdfPCell(new Phrase(" ", font)); c1.setBorder(Rectangle.NO_BORDER); c1.setLeading(4f, 0f); c1.setFixedHeight(15f); table.addCell(c1); c1 = new PdfPCell(new Phrase(" ", font)); c1.setBorder(Rectangle.NO_BORDER); c1.setLeading(4f, 0f); c1.setFixedHeight(15f); table.addCell(c1); } document.add(table); para1 = new Paragraph(); para1.add(new Chunk("E-Signature : ", font)); para1.setAlignment(Element.ALIGN_LEFT); para1.setSpacingAfter(5f); document.add(para1); c1 = new PdfPCell(new Phrase(" ", font)); c1.setBorder(Rectangle.NO_BORDER); c1.setLeading(4f, 0f); c1.setFixedHeight(15f); table.addCell(c1); if (esignature.geteSignaturePhoto() != null) { Image image = Image.getInstance(esignature.geteSignaturePhoto()); para1 = new Paragraph(); para1.add(image); para1.setAlignment(Element.ALIGN_LEFT); para1.setSpacingAfter(5f); document.add(para1); } else { para1 = new Paragraph(); para1.add(""); para1.setAlignment(Element.ALIGN_LEFT); para1.setSpacingAfter(5f); document.add(para1); } } catch (Exception e) { // TODO Auto-generated catch block log.log(Level.INFO, "ApplicationFormPDFMaintenance --> ESingnature " + e.getMessage()); e.printStackTrace(); e.printStackTrace(); LogsMaintenance logsMain = new LogsMaintenance(); StringWriter errors = new StringWriter(); e.printStackTrace(new PrintWriter(errors)); logsMain.insertLogs("ApplicationFormPDFMaintenance", Level.SEVERE + "", errors.toString()); } return document; }
From source file:com.thelinh.gui.PreviewExam.java
private void btnPrintActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnPrintActionPerformed if (this.txtExamCode.getText().equals("")) { JOptionPane.showMessageDialog(this, "Hy nhp m ?"); } else {//from www. ja v a2 s. com JFileChooser fc = new JFileChooser(); FileNameExtensionFilter filter = new FileNameExtensionFilter("PDF files (*.pdf)", "pdf"); fc.setFileFilter(filter); int rt = fc.showSaveDialog(this); if (rt == JFileChooser.APPROVE_OPTION) { String filepath = fc.getSelectedFile().getPath(); if (filepath.indexOf(".") == -1) { filepath = filepath + ".pdf"; } String dafilepath = (new StringBuffer(filepath)).insert(filepath.length() - 4, ".da").toString(); try { Document document = new Document(); PdfWriter.getInstance(document, new FileOutputStream(filepath)); document.open(); // Add title Paragraph p = new Paragraph("Tr?ng ?i h?c Bch Khoa H Ni", timesBold_25); p.setAlignment(Element.ALIGN_CENTER); p.setSpacingAfter(5); document.add(p); p = new Paragraph("?? thi mn " + this.lbSubject.getText(), timesBold_25); p.setAlignment(Element.ALIGN_CENTER); p.setSpacingAfter(25); document.add(p); p = new Paragraph( "Ng?i ra ?: " + Controller.getCurrentAdmin().getAdminName() + ", Ngy ra ?: " + (new SimpleDateFormat("yyyy-MM-dd").format(Calendar.getInstance().getTime())), times_15); p.setAlignment(Element.ALIGN_LEFT); p.setSpacingAfter(5); document.add(p); p = new Paragraph("M ?: " + this.txtExamCode.getText() + " Th?i gian lm bi: " + spTime.getValue().toString() + " pht", timesBold_15); p.setSpacingAfter(25); document.add(p); for (int i = 0; i < this.questionList.size(); i++) { Question question = this.questionList.get(i); ArrayList<Answer> answerList = AnswerSql .getAnswersByQuestionId(question.getQuestionId().trim()); Phrase questionNumber = new Phrase("Cu " + (i + 1) + ": ", timesBold_15); Phrase questionContent = new Phrase(question.getQuestion(), times_15); Paragraph questionTitle = new Paragraph(); questionTitle.add(questionNumber); questionTitle.add(questionContent); document.add(questionTitle); PdfPTable table = new PdfPTable(2); for (int j = 0; j < answerList.size(); j++) { Answer ans = answerList.get(j); Phrase cap = new Phrase(Character.toString((char) (j + 65)) + ". ", timesBold_15); Phrase answerContent = new Phrase(ans.getAnswer(), times_15); Phrase elem = new Phrase(); elem.add(cap); elem.add(answerContent); PdfPCell cell = new PdfPCell(); cell.setBorder(Rectangle.NO_BORDER); cell.setPhrase(elem); cell.setFixedHeight(25); table.addCell(cell); } document.add(table); } document.close(); // if (Desktop.isDesktopSupported()) { // try { // File myFile = new File(filepath); // Desktop.getDesktop().open(myFile); // } catch (IOException ex) { // // no application registered for PDFs // System.out.println(ex.toString()); // } // } document = new Document(); PdfWriter.getInstance(document, new FileOutputStream(dafilepath)); document.open(); // Add title p = new Paragraph("Tr?ng ?i h?c Bch Khoa H Ni", timesBold_25); p.setAlignment(Element.ALIGN_CENTER); p.setSpacingAfter(5); document.add(p); p = new Paragraph("?? thi mn " + this.lbSubject.getText(), timesBold_25); p.setAlignment(Element.ALIGN_CENTER); p.setSpacingAfter(25); document.add(p); p = new Paragraph( "Ng?i ra ?: " + Controller.getCurrentAdmin().getAdminName() + ", Ngy ra ?: " + (new SimpleDateFormat("yyyy-MM-dd").format(Calendar.getInstance().getTime())), times_15); p.setAlignment(Element.ALIGN_LEFT); p.setSpacingAfter(5); document.add(p); p = new Paragraph("M ?: " + this.txtExamCode.getText() + " Th?i gian lm bi: " + spTime.getValue().toString() + " pht", timesBold_15); p.setSpacingAfter(25); document.add(p); for (int i = 0; i < this.questionList.size(); i++) { Question question = this.questionList.get(i); ArrayList<Answer> answerList = AnswerSql .getAnswersByQuestionId(question.getQuestionId().trim()); Phrase questionNumber = new Phrase("Cu " + (i + 1) + ": ", timesBold_15); Phrase questionContent = new Phrase(question.getQuestion(), times_15); Paragraph questionTitle = new Paragraph(); questionTitle.add(questionNumber); questionTitle.add(questionContent); document.add(questionTitle); PdfPTable table = new PdfPTable(2); for (int j = 0; j < answerList.size(); j++) { Answer ans = answerList.get(j); Phrase cap = new Phrase(Character.toString((char) (j + 65)) + ". ", timesBold_15); Phrase answerContent = null; if (ans.getYesNo()) { answerContent = new Phrase(ans.getAnswer(), timesBold_15); } else { answerContent = new Phrase(ans.getAnswer(), times_15); } Phrase elem = new Phrase(); elem.add(cap); elem.add(answerContent); PdfPCell cell = new PdfPCell(); cell.setBorder(Rectangle.NO_BORDER); cell.setPhrase(elem); cell.setFixedHeight(25); table.addCell(cell); } document.add(table); } document.close(); } catch (FileNotFoundException | DocumentException ex) { Logger.getLogger(PreviewExam.class.getName()).log(Level.SEVERE, null, ex); } } } }
From source file:com.timesheet.export.PdfGenerator.java
@Override protected void buildPdfDocument(Map<String, Object> model, Document document, PdfWriter writer, HttpServletRequest request, HttpServletResponse response) throws Exception { /* Add header*/ Font fontHeader = FontFactory.getFont(FontFactory.TIMES_ROMAN, 22, Font.BOLD); Paragraph headerPara = new Paragraph("Time sheet report", fontHeader); headerPara.setSpacingAfter(20f); document.add(headerPara);/*from w w w. ja va2 s . c o m*/ /*Add user info*/ User userProfile = (User) model.get("userprofile"); Font fontUserInfo = FontFactory.getFont(FontFactory.TIMES_ROMAN, 16, Font.BOLD); document.add(new Paragraph("Name : " + userProfile.getName(), fontUserInfo)); document.add(new Paragraph("User no. : " + userProfile.getUserIdentifier(), fontUserInfo)); document.add(new Paragraph("Department : " + userProfile.getDepartment(), fontUserInfo)); document.add(new Paragraph("Email : " + userProfile.getEmail(), fontUserInfo)); Paragraph spacing = new Paragraph(""); spacing.setSpacingAfter(20f); document.add(spacing); PdfPTable table = new PdfPTable(5); table.setWidthPercentage(100.0f); table.setWidths(new float[] { 5.0f, 3.0f, 3.0f, 3.0f, 10.0f }); table.setSpacingBefore(10); // define font for table header row Font font = FontFactory.getFont(FontFactory.TIMES_ROMAN, 12, Font.BOLD); //font.setColor(BaseColor.WHITE); // define table header cell PdfPCell cell = new PdfPCell(); //cell.setBackgroundColor(BaseColor.LIGHT_GRAY); cell.setPadding(5); cell.setBorderWidth(2.0f); cell.setBorder(Rectangle.BOTTOM); // get data model which is passed by the Spring container List<Booking> bookings = (List<Booking>) model.get("bookings"); // write table header cell.setPhrase(new Phrase("Project", font)); table.addCell(cell); // write table header cell.setPhrase(new Phrase("Option", font)); table.addCell(cell); // write table header cell.setPhrase(new Phrase("Date", font)); table.addCell(cell); // write table header cell.setPhrase(new Phrase("Duration", font)); table.addCell(cell); // write table header cell.setPhrase(new Phrase("Description", font)); table.addCell(cell); int sum = 0; Font fontData = FontFactory.getFont(FontFactory.TIMES_ROMAN, 11); for (Booking booking : bookings) { PdfPCell cell1 = new PdfPCell(new Phrase( booking.getProject().getProjectId() + "-" + booking.getProject().getName(), fontData)); cell1.setBorder(Rectangle.BOTTOM); cell1.setPadding(5); table.addCell(cell1); PdfPCell cell2 = new PdfPCell(new Phrase(booking.getBookingOption().getOptionLabel(), fontData)); cell2.setBorder(Rectangle.BOTTOM); cell2.setPadding(5); table.addCell(cell2); PdfPCell cell3 = new PdfPCell(new Phrase(formatDate(booking.getBookingDate()), fontData)); cell3.setBorder(Rectangle.BOTTOM); cell3.setPadding(5); table.addCell(cell3); int hh = booking.getDuration() / 60; int mm = booking.getDuration() % 60; PdfPCell cell4 = new PdfPCell(new Phrase(hh + ":" + mm, fontData)); cell4.setBorder(Rectangle.BOTTOM); cell4.setPadding(5); table.addCell(cell4); PdfPCell cell5 = new PdfPCell( new Phrase(StringEscapeUtils.escapeHtml(booking.getDescription()), fontData)); cell5.setBorder(Rectangle.BOTTOM); cell5.setPadding(5); table.addCell(cell5); sum += booking.getDuration(); } document.add(table); int sumHH = sum / 60; int sumMM = sum % 60; document.add(new Paragraph("Sum : " + sumHH + ":" + sumMM, fontUserInfo)); //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. }
From source file:com.vectorprint.report.itext.style.stylers.SimpleColumns.java
License:Open Source License
/** * writes out content taking into account the current vertical position in the document and making sure that the next * call to {@link Document#add(com.itextpdf.text.Element)} will start at the correct vertical position. * * @see #getSpaceBefore()/*ww w. j a v a 2s . c o m*/ * @see #getSpaceAfter() * * @param last when true space will be appended to start adding content at the correct position after the columns * @throws DocumentException */ public SimpleColumns write(boolean last) throws DocumentException { int status = ColumnText.START_COLUMN; ct.setSimpleColumn(columns.get(column)); if (firstWrite) { float top = getWriter().getVerticalPosition(false) > getTop() ? getTop() : getWriter().getVerticalPosition(false); pageTop = minY = top - getValue(Spacing.SPACEBEFOREPARAM, Float.class); ct.setYLine(pageTop); firstWrite = false; if (log.isLoggable(Level.FINE)) { log.fine(String.format("first write of columns top for content determined: %s", top - getValue(Spacing.SPACEBEFOREPARAM, Float.class))); } } else { if (log.isLoggable(Level.FINE)) { log.fine(String.format("following write of columns, using current top for content: %s", currentY)); } ct.setYLine(currentY); } while (ColumnText.hasMoreText(status)) { if (getSettings().getBooleanProperty(Boolean.FALSE, ReportConstants.DEBUG)) { Rectangle rect = new Rectangle(columns.get(column)); rect.setTop(ct.getYLine()); DebugHelper.debugRect(ct.getCanvas(), rect, new float[] { 2, 2 }, 0.3f, getSettings(), elementProducer); } status = ct.go(); currentY = ct.getYLine(); if (ct.getYLine() < minY) { minY = ct.getYLine(); } if (ColumnText.hasMoreText(status)) { if (column == getNumColumns() - 1) { column = 0; getDocument().newPage(); minY = pageTop = currentY = getTop(); if (log.isLoggable(Level.FINE)) { log.fine(String.format("starting next page for columns")); } } else { column++; if (log.isLoggable(Level.FINE)) { log.fine(String.format("going to column %s", column)); } } ct.setSimpleColumn(columns.get(column)); ct.setYLine(pageTop); } else { contentWritten = addedContent; if (log.isLoggable(Level.FINE)) { log.fine(String.format("column content written %s", addedContent)); } } } if (last) { float space = (pageTop - minY < getBottom()) ? getBottom() + getValue(Spacing.SPACEAFTERPARAM, Float.class) : pageTop - minY + getValue(Spacing.SPACEAFTERPARAM, Float.class); // add necessary spacing, space otherwise ignored! if (log.isLoggable(Level.FINE)) { log.fine(String.format("appending %s mm to start following content at the correct position", ItextHelper.ptsToMm(space))); } Paragraph p = new Paragraph(" "); p.setSpacingAfter(space); getDocument().add(p); } return this; }
From source file:Control.PdfBiglietto.java
/** * Funzione che costruisce il file PDF//ww w. ja v a 2 s . co m * @param nomeFile Nome del file PDF * @param stream Stream sul quale verr scritto il pdf * @throws DocumentException * @throws BadElementException * @throws IOException */ public void costruisciPdf(String nomeFile, OutputStream stream) throws DocumentException, BadElementException, IOException { SimpleDateFormat dataNormale = new SimpleDateFormat("dd/MM/YYYY"); Document biglietto = new Document(); //PdfWriter.getInstance(biglietto, new FileOutputStream(nomeFile)); PdfWriter.getInstance(biglietto, stream); biglietto.open(); biglietto.addAuthor(autore); biglietto.addCreationDate(); biglietto.addCreator(autore); biglietto.addTitle(titolo); //dati inseriti nel QRCode int contatorePrenotazioni = 1; //usato per avere due prenotazioni per ogni pagina for (Prenotazione p : prenotazioni) { contatorePrenotazioni++; StringBuilder sb = new StringBuilder(); sb.append(p.getId()); sb.append("|"); sb.append(p.getUtente().getNome()); sb.append("|"); sb.append(p.getPrezzo()); sb.append("|"); sb.append(p.getSala().getId()); sb.append("|"); sb.append(p.getPosto().getRiga()); sb.append("|"); sb.append(p.getPosto().getColonna()); sb.append("|"); sb.append(p.getSpettacolo().getFilm().getTitolo()); sb.append("|"); sb.append(dataNormale.format(p.getSpettacolo().getData_ora().getTime())); Paragraph completo = new Paragraph(); completo.setSpacingAfter(80.0f); //in caso di problemi al QRcode (dimensioni eccessive, aspetti strani, etc), controllare la stringa in ingresso. QRCode qrBiglietto = new QRCode(sb.toString()); Paragraph titolo = new Paragraph(p.getSpettacolo().getFilm().getTitolo()); titolo.add("\nPrenotazione a nome dell'utente: " + p.getUtente().getNome()); titolo.add(" Id Spettacolo: " + Integer.toString(p.getSpettacolo().getId())); Paragraph info = new Paragraph(); info.add("Lo spettacolo si terr il giorno: "); info.add(dataNormale.format(p.getSpettacolo().getData_ora().getTime())); info.add("\nID Prenotazione: " + Integer.toString(p.getId())); Paragraph sala = new Paragraph(); sala.add("Sala: " + p.getSala().getNome()); sala.add(" Il tuo posto nella riga: " + p.getPosto().getRiga() + " e colonna: " + p.getPosto().getColonna()); Paragraph prezzo = new Paragraph("Pagamento:" + Double.toString(p.getPrezzo())); prezzo.add(" Euro"); Paragraph fondo = new Paragraph("Biglietto emesso in data: " + dataNormale.format(new Date())); fondo.add("\n Mostra questo qrCode all'addetto del cinema: "); Image qrCode = Image.getInstance(qrBiglietto.getQrcode().toByteArray()); qrCode.setAlignment(Image.TOP); if (contatorePrenotazioni % 2 == 0) biglietto.newPage(); completo.add(titolo); completo.add(info); completo.add(sala); completo.add(prezzo); completo.add(fondo); completo.add(qrCode); biglietto.add(completo); } biglietto.close(); }
From source file:crs.Manager_DailyReturnController.java
@FXML private void onDownload(ActionEvent event) { if (report_datepicker.getValue() == null) return;/*from w w w . j a va 2 s. c o m*/ String date = report_datepicker.getValue().toString(); Vlist = CRS.getDailyReturn(date, -1); bdata = getDailyReturnByBranch(date); cdata = getReturnByCategory(date); String filename = report_datepicker.getValue().toString() + "_DailyRental.pdf"; DirectoryChooserBuilder builder = DirectoryChooserBuilder.create(); builder.title("Hello World"); String cwd = System.getProperty("user.dir"); File file = new File(cwd); builder.initialDirectory(file); DirectoryChooser chooser = builder.build(); File chosenDir = chooser.showDialog(null); if (chosenDir != null) { System.out.println(chosenDir.getAbsolutePath()); } else { System.out.print("no directory chosen"); } Document document = new Document(); try { PdfWriter.getInstance(document, new FileOutputStream(chosenDir.getAbsolutePath() + "/" + filename)); document.open(); Paragraph paragraph = new Paragraph(); paragraph.add("Daily Return Report of " + report_datepicker.getValue().toString()); paragraph.setAlignment(Element.ALIGN_CENTER); paragraph.setSpacingAfter(40); document.add(paragraph); document.add(createPDFTableVehicle(Vlist)); paragraph.clear(); paragraph.add(" "); paragraph.setSpacingAfter(20); document.add(paragraph); document.add(createPDFTableByCategory(cdata)); paragraph.setSpacingAfter(20); document.add(paragraph); document.add(createPDFTableByBranch(bdata)); document.close(); label_result.setText("Download successfully"); label_result.setVisible(true); } catch (FileNotFoundException ex) { Logger.getLogger(Manager_ReportController.class.getName()).log(Level.SEVERE, null, ex); } catch (DocumentException ex) { Logger.getLogger(Manager_ReportController.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:crs.Manager_Report_bybranchController.java
@FXML private void onDownload(ActionEvent event) { if (report_datepicker.getValue() == null || combo_loc.getValue() == null) return;/* www .j a v a2 s . c o m*/ String date = report_datepicker.getValue().toString(); bid = getBranchid(combo_loc.getValue().toString()); Vlist = CRS.getDailyRental(date, bid); cdata = getRentalByCategory(date); String filename = report_datepicker.getValue().toString() + "_DailyRental_" + combo_loc.getValue().toString() + ".pdf"; DirectoryChooserBuilder builder = DirectoryChooserBuilder.create(); builder.title("Hello World"); String cwd = System.getProperty("user.dir"); File file = new File(cwd); builder.initialDirectory(file); DirectoryChooser chooser = builder.build(); File chosenDir = chooser.showDialog(null); if (chosenDir != null) { System.out.println(chosenDir.getAbsolutePath()); } else { System.out.print("no directory chosen"); } Document document = new Document(); try { PdfWriter.getInstance(document, new FileOutputStream(chosenDir.getAbsolutePath() + "/" + filename)); document.open(); Paragraph paragraph = new Paragraph(); paragraph.add("Daily Report of " + report_datepicker.getValue().toString() + " location: " + combo_loc.getValue().toString()); paragraph.setAlignment(Element.ALIGN_CENTER); paragraph.setSpacingAfter(40); document.add(paragraph); document.add(createPDFTableVehicle(Vlist)); paragraph.clear(); paragraph.add(" "); paragraph.setSpacingAfter(20); document.add(paragraph); document.add(createPDFTableByCategory(cdata)); document.close(); label_result.setText("Download successfully"); label_result.setVisible(true); } catch (FileNotFoundException ex) { Logger.getLogger(Manager_ReportController.class.getName()).log(Level.SEVERE, null, ex); } catch (DocumentException ex) { Logger.getLogger(Manager_ReportController.class.getName()).log(Level.SEVERE, null, ex); } }