List of usage examples for com.itextpdf.text BaseColor YELLOW
BaseColor YELLOW
To view the source code for com.itextpdf.text BaseColor YELLOW.
Click Source Link
From source file:br.com.ifrn.panfleto.gui.PainelCadastrar.java
public BaseColor corPagina() { if (comboxSelecionarCorPainelGerarPdf.getSelectedItem().equals("Branco")) { return BaseColor.WHITE; } else if (comboxSelecionarCorPainelGerarPdf.getSelectedItem().equals("Preto")) { return BaseColor.BLACK; } else if (comboxSelecionarCorPainelGerarPdf.getSelectedItem().equals("Azul")) { return BaseColor.BLUE; } else if (comboxSelecionarCorPainelGerarPdf.getSelectedItem().equals("Cinza Escuro")) { return BaseColor.DARK_GRAY; } else if (comboxSelecionarCorPainelGerarPdf.getSelectedItem().equals("Cinza")) { return BaseColor.GRAY; } else if (comboxSelecionarCorPainelGerarPdf.getSelectedItem().equals("Cinza Claro")) { return BaseColor.LIGHT_GRAY; } else if (comboxSelecionarCorPainelGerarPdf.getSelectedItem().equals("Magenta")) { return BaseColor.MAGENTA; } else if (comboxSelecionarCorPainelGerarPdf.getSelectedItem().equals("Laranja")) { return BaseColor.ORANGE; } else if (comboxSelecionarCorPainelGerarPdf.getSelectedItem().equals("Rosa")) { return BaseColor.PINK; } else if (comboxSelecionarCorPainelGerarPdf.getSelectedItem().equals("Vermlho")) { return BaseColor.RED; } else if (comboxSelecionarCorPainelGerarPdf.getSelectedItem().equals("Amarero")) { return BaseColor.YELLOW; } else if (comboxSelecionarCorPainelGerarPdf.getSelectedItem().equals("Cyan")) { return BaseColor.CYAN; }//w w w .java2 s . co m return BaseColor.WHITE; }
From source file:com.kohmiho.mpsr.export.PDFGenerator.java
/** * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse * response)/*from w w w . j a va2 s. c o 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("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/company_logo.png"); 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 = { " 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.kohmiho.mpsr.export.PDFGenerator.java
private BaseColor getBackgroundColor(String str) { if ("Green".equals(str) || "On Target".equals(str)) { return BaseColor.GREEN; } else if ("Yellow".equals(str) || "At Risk".equals(str)) { return BaseColor.YELLOW; } else if ("Red".equals(str) || "Off Target".equals(str)) { return BaseColor.RED; }//w w w .j a va 2s . co m return null; }
From source file:com.pma.mpsr.export.PDFGenerator.java
/** * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse * response)// w ww. j av a2 s . c o 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.systemevent.jsfclass.util.PdfEvento.java
public PdfPTable Tabla_compleja() { //creamos una tabla con 3 columnas PdfPTable mitablacompleja = new PdfPTable(3); //aadimos texto con formato a la primera celda PdfPCell celda = new PdfPCell(new Paragraph("Historial de Observaciones", FontFactory.getFont("arial", // fuente 22, // tamao Font.BOLD, // estilo BaseColor.RED))); // color //unimos esta celda con otras 2 celda.setColspan(3);/*w w w . j a v a 2 s .c om*/ //alineamos el contenido al centro celda.setHorizontalAlignment(Element.ALIGN_CENTER); // aadimos un espaciado celda.setPadding(12.0f); //colocamos un color de fondo celda.setBackgroundColor(BaseColor.GRAY); //se aade a la tabla mitablacompleja.addCell(celda); //fila 2 celda = new PdfPCell(new Paragraph("AUDITORIA DE SISTEMAS")); celda.setColspan(2); celda.setBackgroundColor(BaseColor.GREEN); mitablacompleja.addCell(celda); celda = new PdfPCell(new Paragraph("Aprobado")); celda.setBackgroundColor(BaseColor.LIGHT_GRAY); mitablacompleja.addCell(celda); //fila 3 celda = new PdfPCell(new Paragraph("COMPILADORES")); celda.setColspan(2); celda.setBackgroundColor(BaseColor.YELLOW); mitablacompleja.addCell(celda); celda = new PdfPCell(new Paragraph("Reprobado")); celda.setBackgroundColor(BaseColor.LIGHT_GRAY); mitablacompleja.addCell(celda); //fila 4 celda = new PdfPCell(new Paragraph("Prog. Bajo Nivel")); celda.setColspan(2); celda.setBackgroundColor(BaseColor.CYAN); mitablacompleja.addCell(celda); celda = new PdfPCell(new Paragraph("Eximido")); celda.setBackgroundColor(BaseColor.LIGHT_GRAY); mitablacompleja.addCell(celda); //fila 5 mitablacompleja.addCell("Conclusion"); celda = new PdfPCell(new Paragraph("GET A LIFE!!!")); celda.setHorizontalAlignment(Element.ALIGN_RIGHT); celda.setColspan(2); celda.setBackgroundColor(BaseColor.ORANGE); mitablacompleja.addCell(celda); // se retorna la tabla return mitablacompleja; }
From source file:Output.QuotePDf.java
private PdfPTable disclaimerTable(Boolean spotrate, String mtdApproval, String spaceApproval, String overseasResponse) throws DocumentException { PdfPTable table = new PdfPTable(1); table.setWidthPercentage(100f);//w w w. j a va 2 s. c o m table.setSpacingAfter(10f); if (spotrate) { cell = new PdfPCell(new Phrase( "This rate requires special FMC filing. If you intend to book at this rate you must notify sales in writing prior to booking.", fmcFont)); cell.setBackgroundColor(BaseColor.YELLOW); cell.setBorder(Rectangle.NO_BORDER); table.addCell(cell); } if (mtdApproval.equals("Pending") || spaceApproval.equals("Pending") || overseasResponse.equals("Pending")) { cell = new PdfPCell(new Phrase("Rate is subject to final operational acceptance.", fmcFont)); cell.setBackgroundColor(BaseColor.YELLOW); cell.setBorder(Rectangle.NO_BORDER); table.addCell(cell); } cell = new PdfPCell(new Phrase( "Rates quoted are valid for 30 days from date of issue unless otherwise noted.", disclaimerFont)); cell.setBorder(Rectangle.NO_BORDER); table.addCell(cell); cell = new PdfPCell( new Phrase("Any extra charges for special handling are for the shipper's account and arrangement.", disclaimerFont)); cell.setBorder(Rectangle.NO_BORDER); table.addCell(cell); cell = new PdfPCell( new Phrase("Static/towable accessories must move with the main unit for the same rate to apply.", disclaimerFont)); cell.setBorder(Rectangle.NO_BORDER); table.addCell(cell); cell = new PdfPCell(new Phrase( "Please always include the group email kam-roro-sales@us.kline.com in any correspondence.", disclaimerFont)); cell.setBorder(Rectangle.NO_BORDER); table.addCell(cell); cell = new PdfPCell(new Phrase( "Please reference RQS number when booking with customer service (kamricbcarcus@us.kline.com).", disclaimerFont)); cell.setBorder(Rectangle.NO_BORDER); table.addCell(cell); return table; }
From source file:proyectopdf.Pleno.java
public static void main(String a[]) throws FileNotFoundException, DocumentException, IOException { String ae;//from ww w . j a va2 s .c o m JFileChooser jfc = new JFileChooser(); jfc.showOpenDialog(null); BufferedReader archivo = new BufferedReader(new FileReader(jfc.getSelectedFile().getPath())); FileOutputStream nuevo = new FileOutputStream("hola.pdf"); Document documento = new Document(); PdfWriter.getInstance(documento, nuevo); documento.open(); String w; while (archivo.ready()) { ae = archivo.readLine(); StringTokenizer tituloI = new StringTokenizer(ae, "{T}{#T}{C}{#C}{P}{#P}{S}{#S}"); while (tituloI.hasMoreTokens()) { String a1 = tituloI.nextToken(); w = a1; documento.add(new Paragraph(a1, FontFactory.getFont("arial", // fuente 22, // tamao Font.ITALIC, // estilo BaseColor.BLUE))); } String a2 = ""; while (tituloI.hasMoreTokens()) { a2 = tituloI.nextToken(); documento.add(new Paragraph(a2, FontFactory.getFont("arial", // fuente 22, // tamao Font.ITALIC, // estilo BaseColor.RED))); } String a3 = ""; while (tituloI.hasMoreTokens()) { a3 = tituloI.nextToken(); documento.add(new Paragraph(a3, FontFactory.getFont("arial", // fuente 22, // tamao Font.ITALIC, // estilo BaseColor.CYAN))); } String a4 = ""; while (tituloI.hasMoreTokens()) { a4 = tituloI.nextToken(); documento.add(new Paragraph(a4, FontFactory.getFont("arial", // fuente 22, // tamao Font.ITALIC, // estilo BaseColor.YELLOW))); } System.out.println(archivo.readLine()); } documento.close(); }
From source file:servlets.POPDF.java
private void buildpdf(PurchaseOrderDTO dto, HttpServletResponse response) { Font catFont = new Font(Font.FontFamily.HELVETICA, 24, Font.BOLD); Font subFont = new Font(Font.FontFamily.HELVETICA, 16, Font.BOLD); Font smallBold = new Font(Font.FontFamily.HELVETICA, 12, Font.BOLD); String IMG = getServletContext().getRealPath("/img/logo.png"); ByteArrayOutputStream baos = new ByteArrayOutputStream(); Document document = new Document(); VendorDTO venDTO = venModel.getVendor(dto.getVendorno(), ds); DecimalFormat decimal = new DecimalFormat("#0.00"); ArrayList<ProductDTO> products = prodModel.getProdsForVendor(dto.getVendorno(), ds); ArrayList<POLineItemDTO> poLineItems = dto.getItems(); try {/*from w ww. ja v a 2 s . c o m*/ PdfWriter.getInstance(document, baos); document.open(); Paragraph preface = new Paragraph(); // We add one empty line Image image1 = Image.getInstance(IMG); image1.setAbsolutePosition(55f, 760f); preface.add(image1); preface.setAlignment(Element.ALIGN_RIGHT); // Lets write a big header Paragraph mainHead = new Paragraph(String.format("%55s", "Purchase Order"), catFont); preface.add(mainHead); preface.setAlignment(Element.ALIGN_LEFT); preface.add(new Paragraph(String.format("%82s", "PO#: " + dto.getPONumber()), subFont)); addEmptyLine(preface, 3); preface.add(new Paragraph(String.format("%10s", "Vendor: ", smallBold))); preface.add(new Paragraph(String.format("%5s", venDTO.getName(), smallBold))); preface.add(new Paragraph(String.format("%5s", venDTO.getAddress1(), smallBold))); preface.add(new Paragraph(String.format("%5s", venDTO.getCity(), smallBold))); preface.add(new Paragraph(String.format("%5s", venDTO.getProvince(), smallBold))); preface.add(new Paragraph(String.format("%5s", venDTO.getPostalCode(), smallBold))); addEmptyLine(preface, 1); // 3 column table PdfPTable table = new PdfPTable(5); PdfPCell cell = new PdfPCell(new Paragraph("Product Code", smallBold)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(cell); cell = new PdfPCell(new Paragraph("Product Description", smallBold)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(cell); cell = new PdfPCell(new Paragraph("Quantity Sold", smallBold)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(cell); cell = new PdfPCell(new Paragraph("Price", smallBold)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(cell); cell = new PdfPCell(new Paragraph("Ext Price", smallBold)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(cell); for (POLineItemDTO item : poLineItems) { cell = new PdfPCell(new Phrase(item.getproductcode())); cell.setHorizontalAlignment(Element.ALIGN_LEFT); table.addCell(cell); for (ProductDTO prod : products) { if (prod.getProductcode().equals(item.getproductcode())) { cell = new PdfPCell(new Phrase(prod.getProductname())); cell.setHorizontalAlignment(Element.ALIGN_LEFT); table.addCell(cell); } } cell = new PdfPCell(new Phrase(Integer.toString(item.getQuantity()))); cell.setHorizontalAlignment(Element.ALIGN_LEFT); table.addCell(cell); double extPrice = 0.0; for (ProductDTO prod : products) { if (prod.getProductcode().equals(item.getproductcode())) { cell = new PdfPCell(new Phrase(Double.toString(prod.getCostprice()))); cell.setHorizontalAlignment(Element.ALIGN_LEFT); table.addCell(cell); extPrice = prod.getCostprice() * item.getQuantity(); } } String extPriceStr = decimal.format(extPrice); cell = new PdfPCell(new Phrase(extPriceStr)); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); table.addCell(cell); } //end for double sub = dto.getAmount(); double tax = dto.getAmount() * 0.13; double total = dto.getAmount() * 1.13; String taxStr = decimal.format(tax); String totalStr = decimal.format(total); String subStr = decimal.format(sub); cell = new PdfPCell(new Phrase("Total:")); cell.setColspan(4); cell.setBorder(0); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); table.addCell(cell); cell = new PdfPCell(new Phrase(subStr)); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); table.addCell(cell); cell = new PdfPCell(new Phrase("Tax:")); cell.setColspan(4); cell.setBorder(0); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); table.addCell(cell); cell = new PdfPCell(new Phrase(taxStr)); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); table.addCell(cell); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); cell = new PdfPCell(new Phrase("Order Total:")); cell.setColspan(4); cell.setBorder(0); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); table.addCell(cell); cell = new PdfPCell(new Phrase(totalStr)); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); cell.setBackgroundColor(BaseColor.YELLOW); table.addCell(cell); preface.add(table); addEmptyLine(preface, 3); preface.setAlignment(Element.ALIGN_CENTER); preface.add(new Paragraph(String.format("%60s", "Generated on: " + dto.getPODate()), subFont)); document.add(preface); document.close(); // setting some response headers response.setHeader("Expires", "0"); response.setHeader("Cache-Control", "must-revalidate, post-check=0, pre-check=0"); response.setHeader("Pragma", "public"); // setting the content type response.setContentType("application/pdf"); // the contentlength response.setContentLength(baos.size()); // write ByteArrayOutputStream to the ServletOutputStream OutputStream os = response.getOutputStream(); baos.writeTo(os); os.flush(); os.close(); } catch (Exception e) { System.out.println("Error " + e.getMessage()); } }
From source file:servlets.POServlet.java
private void buildpdf(HttpServletResponse response, int ponumber) { Font catFont = new Font(Font.FontFamily.HELVETICA, 24, Font.BOLD); Font subFont = new Font(Font.FontFamily.HELVETICA, 16, Font.BOLD); Font titleFont = new Font(Font.FontFamily.COURIER, 16, Font.BOLD); Font smallBold = new Font(Font.FontFamily.HELVETICA, 12, Font.BOLD); String IMG = getServletContext().getRealPath("/img/logo.png"); ByteArrayOutputStream baos = new ByteArrayOutputStream(); Document document = new Document(); //Get the Purchase Order Items - That way we can access the vendor PurchaseOrderModel poModel = new PurchaseOrderModel(); PurchaseOrderDTO poDTO = poModel.getPurchaseOrder(ponumber, ds); ArrayList<PurchaseOrderLineItemDTO> lineitems = poModel.getLineItemsForPoNumber(ponumber, ds); //Have items, now need to get vendor VendorModel vModel = new VendorModel(); VendorDTO vendor = vModel.getVendor(poDTO.getVendorno(), ds); //Product Model - For looking up product names ProductModel prodMod = new ProductModel(); try {//w ww . j a v a 2s . c om PdfWriter.getInstance(document, baos); document.open(); Paragraph preface = new Paragraph(); // We add one empty line Image image1 = Image.getInstance(IMG); image1.setAbsolutePosition(55f, 650f); image1.scaleAbsolute(200f, 200f); preface.add(image1); preface.add(new Paragraph("Guardians Light Equipment\nBest Exotics in the Cosmos", titleFont)); preface.setAlignment(Element.ALIGN_RIGHT); // Lets write a big header Paragraph mainHead = new Paragraph(String.format("%55s", "Purchase Order"), catFont); preface.add(mainHead); preface.add(new Paragraph(String.format("%82s", "PO#:" + ponumber), subFont)); addEmptyLine(preface, 1); //2 Column Vendor Table PdfPTable vendorTable = new PdfPTable(1); PdfPCell vCell = new PdfPCell(new Phrase("Vendor:", smallBold)); vCell.setHorizontalAlignment(Element.ALIGN_RIGHT); vCell.setBorder(0); vendorTable.addCell(vCell); vendorTable.addCell(GenerateBorderlessCell(vendor.getName(), 0, Element.ALIGN_RIGHT)); vendorTable.addCell(GenerateBorderlessCell(vendor.getAddress1(), 0, Element.ALIGN_RIGHT)); vendorTable.addCell( GenerateBorderlessCell(vendor.getCity() + "," + vendor.getProvince(), 0, Element.ALIGN_RIGHT)); vendorTable.addCell(GenerateBorderlessCell(vendor.getPostalcode(), 0, Element.ALIGN_RIGHT)); preface.add(vendorTable); addEmptyLine(preface, 2); //Generate Headers PdfPTable table = new PdfPTable(5); //Generate the Headers table.addCell(GenerateCellData("Product Code")); table.addCell(GenerateCellData("Product Description")); table.addCell(GenerateCellData("Quantity Sold")); table.addCell(GenerateCellData("Price")); table.addCell(GenerateCellData("Extended Price")); double subTotal = 0.0; for (PurchaseOrderLineItemDTO item : lineitems) { ProductDTO product = prodMod.getProduct(item.getProductcode(), ds); table.addCell(GenerateCellData(product.getProductcode())); table.addCell(GenerateCellData(product.getProductname())); table.addCell(GenerateCellData(String.valueOf(item.getQty()))); double ext = product.getCostprice() * item.getQty(); table.addCell(GenerateCellData("$" + String.format("%.2f", product.getCostprice()))); table.addCell(GenerateCellData("$" + String.format("%.2f", ext))); subTotal += ext; } //Generate Total, Tax, Order Total table.addCell(GenerateBorderlessCell("Subtotal:", 4, Element.ALIGN_RIGHT)); table.addCell(GenerateFinalValue("$" + String.format("%.2f", subTotal))); table.addCell(GenerateBorderlessCell("Tax:", 4, Element.ALIGN_RIGHT)); table.addCell(GenerateFinalValue("$" + String.format("%.2f", subTotal * 0.13))); table.addCell(GenerateBorderlessCell("Order Total:", 4, Element.ALIGN_RIGHT)); PdfPCell totalCell = GenerateFinalValue("$" + String.format("%.2f", poDTO.getTotal())); totalCell.setBackgroundColor(BaseColor.YELLOW); table.addCell(totalCell); preface.add(table); addEmptyLine(preface, 3); preface.setAlignment(Element.ALIGN_CENTER); preface.add(new Paragraph(String.format("%60s", "PO Generated on: " + poDTO.getPodate()), subFont)); document.add(preface); document.close(); // setting some response headers response.setHeader("Expires", "0"); response.setHeader("Cache-Control", "must-revalidate, post-check=0, pre-check=0"); response.setHeader("Pragma", "public"); response.setHeader("Content-Transfer-Encoding", "binary"); response.setHeader("Content-Disposition", "inline; filename=\"sample.PDF\""); response.setContentType("application/octet-stream"); try ( // write ByteArrayOutputStream to the ServletOutputStream OutputStream os = response.getOutputStream()) { baos.writeTo(os); os.flush(); } } catch (Exception e) { System.out.println("Error " + e.getMessage()); } }
From source file:vista.Director.ListaProfesores.java
public void prepararImpresion() throws DocumentException { String ARCHIVO = "/home/master/Documentos/prueba.pdf"; int numFilas = tabProfesor.getRowCount(); Document document = new Document(); Font fuenteTitulo = new Font(Font.FontFamily.TIMES_ROMAN, 18, Font.BOLD); try {//from w w w . j ava 2s.c om PdfWriter.getInstance(document, new FileOutputStream(ARCHIVO)); document.open(); Paragraph parrafo = new Paragraph(); Chunk titulo = new Chunk("Lista de Instructores Registrados", fuenteTitulo); parrafo.add(titulo); parrafo.setAlignment(Element.ALIGN_CENTER); agregarSaltoLinea(parrafo, 3); document.add(parrafo); Paragraph fecha = new Paragraph(); String fechaHoy = obtenerFechaActual(); Chunk datoFecha = new Chunk(fechaHoy); fecha.add(datoFecha); fecha.setAlignment(Element.ALIGN_RIGHT); agregarSaltoLinea(fecha, 3); document.add(fecha); PdfPTable tabla = new PdfPTable(3); tabla.setWidthPercentage(70); PdfPCell cell1 = new PdfPCell(new Phrase("Nombre")); cell1.setBackgroundColor(BaseColor.YELLOW); cell1.setHorizontalAlignment(Element.ALIGN_CENTER); PdfPCell cell2 = new PdfPCell(new Phrase("Apellido")); cell2.setBackgroundColor(BaseColor.YELLOW); cell2.setHorizontalAlignment(Element.ALIGN_CENTER); PdfPCell cell3 = new PdfPCell(new Phrase("CI")); cell3.setBackgroundColor(BaseColor.YELLOW); cell3.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(cell1); tabla.addCell(cell2); tabla.addCell(cell3); for (int i = 0; i < numFilas; i++) { Object obj1 = obtenerDato(tabProfesor, i, 1); Object obj2 = obtenerDato(tabProfesor, i, 2); Object obj3 = obtenerDato(tabProfesor, i, 3); String valor1 = obj1.toString(); String valor2 = obj2.toString(); String valor3 = obj3.toString(); tabla.addCell(valor1); tabla.addCell(valor2); tabla.addCell(valor3); } document.add(tabla); document.close(); } catch (FileNotFoundException ex) { System.err.println(ex); } }