List of usage examples for com.itextpdf.text Font UNDERLINE
int UNDERLINE
To view the source code for com.itextpdf.text Font UNDERLINE.
Click Source Link
From source file:com.pma.mpsr.export.PDFGenerator.java
/** * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse * response)/*from www .j av a 2s . 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.swayam.bhasha.engine.io.writers.impl.PDFGenerator.java
License:Apache License
private Paragraph getParagraph(Para para) throws DocumentException, IOException, DocGenerationException { int align = para.getAlignment(); int pdfAlign; switch (align) { case Para.CENTER: pdfAlign = Paragraph.ALIGN_CENTER; break;//w w w .j av a 2 s . c o m case Para.RIGHT: pdfAlign = Paragraph.ALIGN_RIGHT; break; case Para.JUSTIFIED: pdfAlign = Paragraph.ALIGN_JUSTIFIED; break; case Para.LEFT: default: pdfAlign = Paragraph.ALIGN_LEFT; break; } List<ParaText> paraTextList = para.getParaTextList(); Paragraph paragraph = new Paragraph(); paragraph.setAlignment(pdfAlign); for (ParaText paraText : paraTextList) { int fontStyle = Font.NORMAL; if (paraText.isBold()) { fontStyle |= Font.BOLD; } if (paraText.isUnderline()) { fontStyle |= Font.UNDERLINE; } if (paraText.isItalic()) { fontStyle |= Font.ITALIC; } Font font = FontFactory.getFont(paraText.getFontFamily(), BaseFont.IDENTITY_H, BaseFont.EMBEDDED, paraText.getFontSize(), fontStyle, new BaseColor(paraText.getColor().getRGB())); // its very important to set the leading every time the font is set // otherwise, the chunks/phrases overlap. // paragraph.setLeading(font.getSize() * 1.5f); paragraph.add(new Phrase(paraText.getText(), font)); } return paragraph; }
From source file:com.vectorprint.report.itext.debug.DebugHelper.java
License:Open Source License
public static Font debugFontLink(PdfContentByte canvas, EnhancedMap settings) { BaseFont bf = debugFont(canvas, settings); return new Font(bf, 8, Font.UNDERLINE, itextHelper.fromColor(settings.getColorProperty(Color.MAGENTA, ReportConstants.DEBUGCOLOR))); }
From source file:Controlador.ControladorClasificacion.java
/** * Mtodo generarPDF que genera el PDF con la clasificacin al pulsar el * botn generar PDF/*from w w w . ja v a2 s. c o m*/ * * @throws FileNotFoundException salta la excepcion * @throws DocumentException salta la excepcion * @throws IOException salta la excepcion */ public void generarPDF() throws FileNotFoundException, DocumentException, IOException { Calendar cal = Calendar.getInstance(); String time = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss").format(cal.getTime()); File file = new File("Clasificacion.pdf"); FileOutputStream fileout = new FileOutputStream(file.getAbsolutePath()); Document document = new Document(); PdfWriter.getInstance(document, fileout); Font fuente1 = new Font(); Font fuente2 = new Font(); Font fuente3 = new Font(); fuente1.setStyle(Font.BOLD | Font.ITALIC | Font.UNDERLINE); fuente1.setSize(18); fuente1.setColor(0, 51, 204); fuente2.setStyle(Font.BOLD | Font.ITALIC); fuente2.setColor(0, 51, 204); fuente2.setSize(13); fuente3.setStyle(Font.BOLD | Font.ITALIC); fuente3.setSize(16); fuente3.setColor(255, 153, 0); document.open(); Paragraph pa = new Paragraph("Fecha y hora: " + time); pa.setAlignment(Element.ALIGN_RIGHT); document.add(pa); /*String url = "imagenPDF.jpg"; File file2 = new File(url); FileInputStream filein = new FileInputStream(file2.getAbsolutePath()); //String url = "./imagenPDF.jpg"; Image imagen = Image.getInstance(filein.getFD()); //System.out.println(file2.getAbsolutePath()); imagen.scalePercent(20); document.add(imagen);*/ document.add(new Paragraph("\n")); Paragraph p3 = new Paragraph("GESTOR DE CAMPEONATO DE BALONCESTO", fuente1); p3.setAlignment(Element.ALIGN_CENTER); document.add(p3); document.add(new Paragraph("\n")); String tipo_competicion = FicherosTipo.leerFichero(); if (tipo_competicion.contains("Copa")) { Paragraph pa1 = new Paragraph("COPA", fuente3); pa1.setAlignment(Element.ALIGN_CENTER); document.add(pa1); document.add(new Paragraph( "---------------------------------------------------------------------------------------------------------------------------------")); document.add(new Paragraph("\n")); int jornada_maxima = PartidoDAO.obtenerJornadaActual(); for (int i = jornada_maxima; i > 0; i--) { List<Partido> listarPartidosJornada = PartidoDAO.listarPartidosJornada(i); for (Partido p : listarPartidosJornada) { List<PartidoJugado> listarEquiposporPartido = PartidoJugadoDAO .listarEquiposporPartido(p.getIdPartido()); int equipoA = listarEquiposporPartido.get(0).getIdEquipo(); int equipoB = listarEquiposporPartido.get(1).getIdEquipo(); Paragraph p2 = new Paragraph( "Equipo A: " + EquipoDAO.obtenerNombreEquipo(equipoA) + " - Equipo B: " + EquipoDAO.obtenerNombreEquipo(equipoB) + " - Resultado: " + p.getResultado(), fuente2); p2.setAlignment(Element.ALIGN_LEFT); document.add(p2); } } } else if (tipo_competicion.contains("Liga")) { Paragraph pa1 = new Paragraph("LIGA", fuente3); pa1.setAlignment(Element.ALIGN_LEFT); document.add(pa1); document.add(new Paragraph( "---------------------------------------------------------------------------------------------------------------------------------")); document.add(new Paragraph("\n")); List<Equipo> obtenerTodosEquipos = EquipoDAO.obtenerTodosEquipos(); Collections.sort(obtenerTodosEquipos); System.out.println(obtenerTodosEquipos); for (Equipo p : obtenerTodosEquipos) { Paragraph pa2 = new Paragraph(p.getNombre(), fuente2); pa2.setAlignment(Element.ALIGN_LEFT); document.add(pa2); } } document.close(); File myfile = new File("Clasificacion.pdf"); Desktop.getDesktop().open(myfile); }
From source file:Controlador.ControladorCrearPase.java
public void generaPDF(String Prueba, String Causa, Integer idCita, Integer idPaciente, Integer idPersona) throws FileNotFoundException, DocumentException, IOException { Calendar cal = Calendar.getInstance(); String time = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss").format(cal.getTime()); String timename = new SimpleDateFormat("yyyyMMddHHmm").format(cal.getTime()); File file = new File("PaseServicio" + timename + ".pdf"); FileOutputStream fileout = new FileOutputStream(file); Document document = new Document(); PdfWriter writer;/*from ww w . j a va 2 s .co m*/ writer = PdfWriter.getInstance(document, fileout); Font fuente = new Font(); Font fuente2 = new Font(); Font fuente3 = new Font(); // fuente.setColor(BaseColor.BLUE); fuente.setStyle(Font.UNDERLINE | Font.BOLDITALIC); fuente2.setStyle(Font.BOLD); fuente2.setSize(12); fuente3.setSize(20); fuente3.setStyle(Font.BOLD); document.open(); document.add(new Paragraph("\n \n \n \n \n")); document.add(new Paragraph("Clinica Mdica INFTEL", fuente3)); String imageUrl = "src/Imagen/logo.png"; // String imagen="src\Imagen\logo.png"; Image image = Image.getInstance(imageUrl); image.setAbsolutePosition(300, 750); image.scalePercent(80f); document.add(image); document.add(new Paragraph(" ")); document.add(new Paragraph("---------------------")); document.add(new Paragraph("DATOS DEL PACIENTE", fuente)); document.add(new Paragraph(" ")); document.add( new Paragraph("Apellidos y Nombre : " + paciente.getApellidos() + ", " + paciente.getNombre())); document.add(new Paragraph("NIF : " + paciente.getNif())); document.add(new Paragraph("NSS : " + paciente.getNumSS())); document.add(new Paragraph("Direccion : " + paciente.getDireccion())); document.add(new Paragraph("Telefono : " + paciente.getTelefono())); document.add(new Paragraph("Email : " + paciente.getEmail())); document.add(new Paragraph("ID Paciente : " + idPaciente)); document.add(new Paragraph(" ")); document.add(new Paragraph("---------------------")); document.add(new Paragraph(" ")); document.add(new Paragraph("DATOS ", fuente)); document.add(new Paragraph(" ")); document.add(new Paragraph(" ")); document.add(new Paragraph("Prueba : ", fuente2)); document.add(new Paragraph(Prueba)); document.add(new Paragraph(" ")); document.add(new Paragraph(" ")); document.add(new Paragraph("Causa : ", fuente2)); document.add(new Paragraph(Causa)); document.add(new Paragraph(" ")); document.add(new Paragraph(" ")); absText(writer, time, 450, 50); document.close(); File myfile = new File("PaseServicio" + timename + ".pdf"); Desktop.getDesktop().open(myfile); }
From source file:Controlador.PDF.java
public String escribePDF(String nombre) { FileOutputStream ficheroPdf = null; Random r = new Random(); r.setSeed(System.currentTimeMillis()); String f_nombre = "cons" + nombre + r.nextInt(9000) + ".pdf"; try {/* w w w.j a va2 s. co m*/ Document documento = new Document(); String basePath = new File("").getAbsolutePath(); String[] parts = basePath.split("/"); final String path = "/" + parts[1] + "/" + parts[2] + "/NetBeansProjects/pag_ingles/web/" + f_nombre; ficheroPdf = new FileOutputStream(path); PdfWriter.getInstance(documento, ficheroPdf).setInitialLeading(20); documento.open(); Image foto = Image.getInstance( "/" + parts[1] + "/" + parts[2] + "/NetBeansProjects/pag_ingles/web/img/escuela.png"); foto.scaleToFit(200, 200); foto.setAlignment(Chunk.ALIGN_RIGHT); documento.add(foto); documento.add(new Paragraph(" ")); documento.add(new Paragraph(" ")); documento.add(new Paragraph(" ")); documento.add(new Paragraph("Darktech Anglo Institute", FontFactory.getFont("Courier-Bold", 30, Font.UNDERLINE, BaseColor.BLUE))); documento.add(new Paragraph(" ")); documento.add(new Paragraph(" ")); documento.add(new Paragraph(" ")); documento.add(new Paragraph(" OTORGA LA PRESENTEaaa", FontFactory.getFont("ARIAL", 30, Font.NORMAL, BaseColor.BLACK))); documento.add(new Paragraph(" ")); documento.add(new Paragraph(" ")); documento.add(new Paragraph(" ")); documento.add(new Paragraph(" CONSTANCIA", FontFactory.getFont("ARIAL", 30, Font.NORMAL, BaseColor.BLACK))); documento.add(new Paragraph(" ")); documento.add(new Paragraph(" ")); documento.add(new Paragraph(" ")); documento.add(new Paragraph(" ")); documento.add(new Paragraph(" A : " + nombre, FontFactory.getFont("ARIAL", 20, Font.BOLD, BaseColor.BLACK))); documento.add(new Paragraph(" ")); documento.add(new Paragraph(" ")); documento.add(new Paragraph(" ")); documento.add(new Paragraph(" ")); documento.add(new Paragraph("POR HABER CONCLUIDO CON EXITO EL CURSO DE INGLES.", FontFactory.getFont("ARIAL", 14, Font.NORMAL, BaseColor.BLACK))); documento.close(); ficheroPdf.close(); Thread.sleep(3000); } catch (DocumentException | FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } catch (InterruptedException ex) { Logger.getLogger(PDF.class.getName()).log(Level.SEVERE, null, ex); } finally { try { ficheroPdf.close(); } catch (IOException e) { e.printStackTrace(); } } return f_nombre; }
From source file:controller.PdfManager.java
/** * This method will generate an pdf for the applicant * @param email the email of the user/* ww w. j a va 2 s . co m*/ * @param competences the competences that the applican has added * @param dates the availability periods that the applicant added * @throws IOException */ public void downloadPDF(String email, List<CompetenceProfileDTO> competences, List<String> dates) throws IOException { FacesContext facesContext = FacesContext.getCurrentInstance(); ExternalContext externalContext = facesContext.getExternalContext(); HttpServletResponse response = (HttpServletResponse) externalContext.getResponse(); try { Font font1 = new Font(Font.FontFamily.HELVETICA, 30, Font.BOLD); Font font2 = new Font(Font.FontFamily.HELVETICA, 25, Font.UNDERLINE); Font font3 = new Font(Font.FontFamily.HELVETICA, 14); Document document = new Document(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); PdfWriter.getInstance(document, baos); document.open(); Paragraph h1 = new Paragraph("" + email + " Application", font1); h1.setAlignment(Element.ALIGN_CENTER); document.add(h1); //Add all competences document.add(new Paragraph("Competences", font2)); for (CompetenceProfileDTO s : competences) { document.add(new Paragraph( "Work: " + s.getName() + " Years of Experience: " + s.getYearsOfExperience() + " ", font3)); } document.add(new Paragraph("Availability", font2)); for (String ava : dates) { document.add(new Paragraph("" + ava + "", font3)); } 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-Disposition", "inline; filename=\"" + email + "\".pdf"); 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 (DocumentException e) { throw new IOException(e.getMessage()); } }
From source file:dbms.Bills1Controller.java
@FXML void OnMouseClick(ActionEvent event) throws ClassNotFoundException, SQLException, FileNotFoundException, DocumentException { int c = check(phone_no.getText()); int c1 = phone_no.getText().length(); String s1 = product_id.getText(); String s3 = cb1.getSelectionModel().getSelectedItem(); String s7 = cb2.getSelectionModel().getSelectedItem(); int s8 = cb3.getSelectionModel().getSelectedItem(); String s2 = cust_name.getText(); String s4 = address.getText(); String s6 = date.getValue().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")); String s5 = phone_no.getText(); String s10 = total.getText(); String s11 = cb4.getSelectionModel().getSelectedItem(); String s12 = payment.getText(); int to = Integer.parseInt(s10); if (c == 0 || c1 != 10 || total.getText().equals("") || cust_name.getText().equals("") || address.getText().equals("") || payment.getText().equals("")) { JOptionPane.showMessageDialog(null, "Something is wrong"); } else {// w ww. j a va 2 s .c o m try { Class.forName("com.mysql.jdbc.Driver"); java.sql.Connection con = DriverManager .getConnection("jdbc:mysql://localhost/dbms?user=root&password=india123"); String str1 = "insert into sold_item values(?,?,?,?,?,?,?,?,?,?)"; // System.out.println(str1); java.sql.PreparedStatement stmt1 = con.prepareStatement(str1); stmt1.setString(1, s1); stmt1.setString(2, s3); stmt1.setString(3, s7); stmt1.setInt(4, s8); stmt1.setString(5, s2); stmt1.setString(6, s4); stmt1.setString(7, s5); stmt1.setString(8, s6); stmt1.setInt(9, to); stmt1.setString(10, s11); // ResultSet rs1 = stmt1.executeQuery(); stmt1.executeUpdate(); // con.close(); JOptionPane.showMessageDialog(null, "Bill Generated"); String str6 = "select * from sold_item where billid= '" + s1 + "'"; PreparedStatement stmt2 = con.prepareStatement(str6); ResultSet rs = stmt2.executeQuery(str6); Document my_bill = new Document(); PdfWriter.getInstance(my_bill, new FileOutputStream(s1 + ".pdf")); my_bill.open(); Font f1 = new Font(FontFamily.TIMES_ROMAN, 20.0f, Font.BOLD, BaseColor.BLACK); Paragraph p2 = new Paragraph("XYZ Electronics", f1); p2.setAlignment(Paragraph.ALIGN_CENTER); my_bill.add(p2); //my_bill.add(Chunk.NEWLINE); Paragraph p3 = new Paragraph("BILL", f1); p3.setAlignment(Paragraph.ALIGN_CENTER); my_bill.add(p3); my_bill.add(Chunk.NEWLINE); PdfPTable bill_table = new PdfPTable(2); PdfPCell table_cell; while (rs.next()) { bill_table.addCell("Bill ID"); String dept_id = rs.getString(1); table_cell = new PdfPCell(new Phrase(dept_id)); bill_table.addCell(table_cell); bill_table.addCell("Product Type"); String dept_name = rs.getString(2); table_cell = new PdfPCell(new Phrase(dept_name)); bill_table.addCell(table_cell); bill_table.addCell("Product name"); String dept_pname = rs.getString(3); table_cell = new PdfPCell(new Phrase(dept_pname)); bill_table.addCell(table_cell); bill_table.addCell("Quantity"); int dept_quan = rs.getInt(4); table_cell = new PdfPCell(new Phrase("" + dept_quan)); bill_table.addCell(table_cell); bill_table.addCell("Customer Name"); String manager_id = rs.getString(5); table_cell = new PdfPCell(new Phrase(manager_id)); bill_table.addCell(table_cell); bill_table.addCell("Address"); String location_id = rs.getString(6); table_cell = new PdfPCell(new Phrase(location_id)); bill_table.addCell(table_cell); bill_table.addCell("Phone Number"); String s = rs.getString(7); table_cell = new PdfPCell(new Phrase(s)); bill_table.addCell(table_cell); bill_table.addCell("DATE"); String ss = rs.getString(8); table_cell = new PdfPCell(new Phrase(ss)); bill_table.addCell(table_cell); bill_table.addCell("Total"); int dept_total = rs.getInt(9); table_cell = new PdfPCell(new Phrase("Rs. " + dept_total)); bill_table.addCell(table_cell); } my_bill.add(bill_table); my_bill.add(Chunk.NEWLINE); Font f2 = new Font(FontFamily.TIMES_ROMAN, 20.0f, Font.UNDERLINE, BaseColor.BLACK); Paragraph p4 = new Paragraph("Manager Signature", f1); p4.setAlignment(Paragraph.ALIGN_RIGHT); my_bill.add(p4); my_bill.close(); String spl[] = s7.split("-"); String strr = "select Quantity from " + s3 + " where Company = '" + spl[0] + "' and ProductName = '" + spl[1] + "'"; PreparedStatement stmt3 = con.prepareStatement(strr); ResultSet rs3 = stmt3.executeQuery(); rs3.next(); int f = rs3.getInt(1); f = f - s8; String strr1 = "Update " + s3 + " set Quantity = " + f + " where Company = '" + spl[0] + "' and ProductName = '" + spl[1] + "' "; PreparedStatement stmt4 = con.prepareStatement(strr1); stmt4.executeUpdate(); String strr2 = "insert into payment values(?,?)"; PreparedStatement stmt5 = con.prepareStatement(strr2); stmt5.setString(1, product_id.getText()); stmt5.setString(2, payment.getText()); stmt5.executeUpdate(); rs.close(); stmt2.close(); con.close(); product_id.setText(""); // prdct_name.setText(""); cust_name.setText(""); address.setText(""); phone_no.setText(""); } catch (DocumentException | HeadlessException | FileNotFoundException | ClassNotFoundException | SQLException e) { JOptionPane.showMessageDialog(null, e.getMessage()); } } }
From source file:edu.cornell.mannlib.vitro.webapp.visualization.visutils.PDFDocument.java
License:Open Source License
public PDFDocument(String authorName, Map<String, Integer> yearToPublicationCount, Document document, PdfWriter pdfWriter) {/*from w ww .ja va2 s .c o m*/ // setPreferredSize(new Dimension(600,400)); try { document.addTitle("PDF Pipeline iText Prototype"); document.addAuthor(authorName); document.addSubject("This example tests text, color, image, transparency & table functionality."); document.addKeywords("text, color, image, transparency, table"); document.addCreator("Standalone PDF Renderer using iText"); Paragraph header = new Paragraph(); Font pageHeaderStyle = FontFactory.getFont(FontFactory.TIMES_ROMAN, 15, Font.BOLDITALIC | Font.UNDERLINE); Font featureHeaderStyle = FontFactory.getFont(FontFactory.TIMES_ROMAN, 10, new BaseColor(Color.red)); header.add(new Chunk("PDF Pipeline Prototype v2 using iText\n", pageHeaderStyle)); header.setSpacingAfter(15f); document.add(header); Paragraph content = new Paragraph(); content.add(new Chunk("Publication Count - Author Name - " + authorName, featureHeaderStyle)); content.setSpacingAfter(15f); document.add(content); // step4 PdfPTable publicationCount = createTable(yearToPublicationCount); document.add(publicationCount); content = new Paragraph(); content.add(new Chunk("Transparency of Shapes", featureHeaderStyle)); content.setSpacingAfter(15f); document.add(content); createTransparencyShapes(document, pdfWriter); createImage(document, pdfWriter, featureHeaderStyle); } catch (DocumentException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } }
From source file:Export.CertificadoCargaMaritima.java
public String criarDoc(String numApolice, String numCliente, Contrato c, CargaMaritimaBean cm, String user, String moeda, String arquivo) { try {//w w w.ja v a2 s . c om SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy hh'.'mm'.'ss"); Font fontCabecalhoN = FontFactory.getFont(Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 9.5f); Font fontCorpo = FontFactory.getFont(Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 9f); Font fontCorpoP = FontFactory.getFont(Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 8f); Font fontCorpoN = FontFactory.getFont(Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 9f); Font fontCorpoNG = FontFactory.getFont(Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 10f); Font fontCabecalhoNG = FontFactory.getFont(Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 16f, Font.UNDERLINE); Font fontUK = FontFactory.getFont(Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 5.5f, Font.ITALIC); PdfPTable pTableEmpresaPricipal = new PdfPTable(new float[] { 25f, 75f }); PdfPTable pTableEmpresaInforImpres1 = new PdfPTable(1); PdfPTable pTableEmpresaInforImpres2 = new PdfPTable(1); PdfPTable pTableEmpresaInforImpres5 = new PdfPTable(1); PdfPTable pTableNull = new PdfPTable(1); PdfPCell cellNull = new PdfPCell(new Phrase(" ", fontCorpo)); cellNull.setBorder(0); pTableNull.addCell(cellNull); PdfPCell pCellNomeEmpresa = new PdfPCell(new Phrase(Empresa.NOME, fontCabecalhoNG)); pCellNomeEmpresa.setBorder(0); PdfPCell pCellNomeEndereco = new PdfPCell(new Phrase(Empresa.ENDERECO, fontCabecalhoN)); pCellNomeEndereco.setBorder(0); PdfPCell pCellCaixaPostal = new PdfPCell(new Phrase(Empresa.CAIXAPOSTAL, fontCabecalhoN)); pCellCaixaPostal.setBorder(0); PdfPCell pCellTeleFax = new PdfPCell( new Phrase(Empresa.TELEFAX + " " + ConfigDoc.Empresa.EMAIL, fontCabecalhoN)); pCellTeleFax.setBorder(0); PdfPCell pCellSociedade = new PdfPCell(new Phrase(Empresa.SOCIEDADE, fontCabecalhoN)); pCellSociedade.setBorder(0); PdfPCell pCellPolice = new PdfPCell(new Phrase(Empresa.APOLICE + numApolice, fontCabecalhoN)); pCellPolice.setBorder(0); Image imageEmpresa = Image.getInstance("logo.png"); imageEmpresa.scaleToFit(120f, 85f); pTableEmpresaInforImpres1.addCell(pCellNomeEmpresa); pTableEmpresaInforImpres1.addCell(pCellNomeEndereco); pTableEmpresaInforImpres1.addCell(pCellCaixaPostal); pTableEmpresaInforImpres1.addCell(pCellTeleFax); pTableEmpresaInforImpres1.addCell(pCellSociedade); pTableEmpresaInforImpres1.addCell(pCellPolice); PdfPCell cellTabela3 = new PdfPCell(pTableEmpresaInforImpres1); cellTabela3.setBorder(0); pTableEmpresaInforImpres5.addCell(cellTabela3); PdfPCell cellTabela5 = new PdfPCell(pTableEmpresaInforImpres5); cellTabela5.setBorder(0); PdfPCell cellTabela6 = new PdfPCell(imageEmpresa); cellTabela6.setBorder(0); pTableEmpresaPricipal.addCell(cellTabela6); pTableEmpresaPricipal.addCell(cellTabela5); PdfPTable pTableTitulo = new PdfPTable(1); Phrase pTitulo = new Phrase("CErtificado Seguro de Carga Maritima".toUpperCase(), fontCorpoNG); pTitulo.add(new Phrase("\nMARINE CARGO CERTIFICATE", fontUK)); PdfPCell cellTitulo = new PdfPCell(pTitulo); cellTitulo.setBorder(0); cellTitulo.setHorizontalAlignment(Element.ALIGN_CENTER); pTableTitulo.addCell(cellTitulo); PdfPTable pTableCorpoUm = new PdfPTable(new float[] { 100 }); PdfPTable pTableCorpoDois = new PdfPTable(new float[] { 50, 50 }); PdfPTable pTableCorpoTres = new PdfPTable(new float[] { 100 }); PdfPCell cellCorpopUm = new PdfPCell(); cellCorpopUm.setBorder(0); PdfPCell cellCorpopDois1 = new PdfPCell(); cellCorpopDois1.setBorder(0); PdfPCell cellCorpopDois2 = new PdfPCell(); cellCorpopDois2.setBorder(0); PdfPCell cellCorpopTres = new PdfPCell(); cellCorpopTres.setBorder(0); Paragraph pCorpoUm1 = new Paragraph( "Certificado de seguro emitido sob contracto aberto n".toUpperCase(), fontCorpoN); pCorpoUm1.add( new Phrase("\ncertificate OF insurance issued under contract open No.".toUpperCase(), fontUK)); Paragraph pCorpoUm2 = new Paragraph("mbito da cobertura: ".toUpperCase(), fontCorpoN); pCorpoUm2.add(new Phrase("\nSCOPE OF COVER", fontUK)); Paragraph pCorpoUm3 = new Paragraph( "Este certificado atesta que a Companhia tem as mencionadas, sob seguro para viagem (s) e valore (s) declarados em favor de", fontCorpo); pCorpoUm3.add(new Phrase( "\nTHIS IS TO CERTIFY THAT THE COMPANY HAS INSURED THE UNDER MENTIONED GOODS FOR THE VOYGE (S) AND VALUE (S) STATED ON BEHALF OF", fontUK)); cellCorpopUm.addElement(pCorpoUm1); cellCorpopUm.addElement(pCorpoUm2); cellCorpopUm.addElement(pCorpoUm3); pTableCorpoUm.addCell(cellCorpopUm); Paragraph pCorpoDois11 = new Paragraph("Taxa Maritima: ", fontCorpo); pCorpoDois11.add(new Phrase("\nMARINE RATE", fontUK)); Paragraph pCorpoDois12 = new Paragraph("Taxa Guerra: ", fontCorpo); pCorpoDois12.add(new Phrase("\nWAR RATE", fontUK)); cellCorpopDois1.addElement(pCorpoDois11); cellCorpopDois1.addElement(pCorpoDois12); pTableCorpoDois.addCell(cellCorpopDois1); cellCorpopUm.addElement(pCorpoUm1); cellCorpopUm.addElement(pCorpoUm2); Paragraph pCorpoDois21 = new Paragraph("Nota de Bebito: ", fontCorpo); pCorpoDois21.add(new Phrase("\nDEBIT NOTE NO", fontUK)); Paragraph pCorpoDois22 = new Paragraph("Total de Prmio: ", fontCorpo); pCorpoDois22.add(new Phrase("\nGROSS PREMIUM", fontUK)); cellCorpopDois2.addElement(pCorpoDois21); cellCorpopDois2.addElement(pCorpoDois22); pTableCorpoDois.addCell(cellCorpopDois2); Paragraph pCorpoTres1 = new Paragraph("Taxa Superintendente: ", fontCorpo); pCorpoTres1.add(new Phrase("\nSuperintendent RATE".toUpperCase(), fontUK)); Paragraph pCorpoTres2 = new Paragraph("Taxa Interna de Trnsito: ", fontCorpo); pCorpoTres2.add(new Phrase("\nINLANDTraffic Rate", fontUK)); Paragraph pCorpoTres3 = new Paragraph("Taxa Total: ", fontCorpo); pCorpoTres3.add(new Phrase("\nTOTAL RATE", fontUK)); Paragraph pCorpoTres4 = new Paragraph("Segurado: ", fontCorpo); pCorpoTres4.add(new Phrase("\nInsured".toUpperCase(), fontUK)); Paragraph pCorpoTres5 = new Paragraph("Meio de Transporte: " + cm.getCargaMaritima().getFormaEnvio(), fontCorpo); pCorpoTres5.add(new Phrase("\nMODE OF CONVEYANCE", fontUK)); //Paragraph pCorpoTres6_1 = new Paragraph("Medadoria Assegurada: ",fontCorpo); Paragraph pCorpoTres6 = new Paragraph("De " + cm.getCargaMaritima().getPaisOrigem() + " Para: " + cm.getCargaMaritima().getPaisDestino(), fontCorpo); pCorpoTres6.add(new Phrase("\nFROM TO", fontUK)); Paragraph pCorpoTres7 = new Paragraph("Juros: ", fontCorpo); pCorpoTres7.add(new Phrase("\nINTEREST", fontUK)); Paragraph pCorpoTres8 = new Paragraph("Valor Segurado: ", fontCorpo); pCorpoTres8.add(new Phrase("\nINSURED VALUE", fontUK)); Paragraph pCorpoTres9 = new Paragraph( "CONDIES: Sujeitas as seguintes clsulas e garantias (Ver anexo A)", fontCorpoN); pCorpoTres9.add(new Phrase( "\nCONDITIONS : Subject to the following clsulas and warranteis (SEE APPENDICIX A)", fontUK)); Paragraph pCorpoTres10 = new Paragraph( "No caso de perda ou dano que se presume a companhia ser reponsvel, deve-se comunicar de imediato NICOM SEGUROS STP" + " para ser feita a vistoria (Por favor volte).", fontCorpo); pCorpoTres10.add(new Phrase( "\nIn the event of loss or damage for which company is presumed to be liable, immediate resquest for survey must be made to NICON SEGUROS STP (PLEASE TURN OVER).", fontUK)); Paragraph pCorpoTres11 = new Paragraph( "No caso de perda ou dano este certificado, depois de autenticado, deve ser anexo a reclamao acompanhado" + " de relatrio de auditoria e da factura original do desembarque, a cpia autenticada ou original da factura e uaisquer outros documentos relativo.", fontCorpo); pCorpoTres10.add(new Phrase( "\nIn case of loss or damage this certificate, must be annexed to the claim note accompaneid by the repost, original bill of landing, true copy" + " or original invoice and any other relevant documenent.", fontUK)); Paragraph pCorpoTres12 = new Paragraph(); Phrase p1 = new Phrase("Nota: ", fontCorpoN); Phrase p2 = new Phrase( "A Empresa compromete-se a emitir uma aplice que cobre as mercadorias descritas no pedido", fontCorpo); Phrase p3 = new Phrase( "\nThe Company undertakes to issue a policy covering the good described herein on request.", fontUK); pCorpoTres12.add(p1); pCorpoTres12.add(p2); pCorpoTres12.add(p3); cellCorpopTres.addElement(pCorpoTres1); cellCorpopTres.addElement(pCorpoTres2); cellCorpopTres.addElement(pCorpoTres3); cellCorpopTres.addElement(pCorpoTres4); cellCorpopTres.addElement(pCorpoTres5); //cellCorpopTres.addElement(pCorpoTres6_1); cellCorpopTres.addElement(pCorpoTres6); cellCorpopTres.addElement(pCorpoTres7); cellCorpopTres.addElement(pCorpoTres8); cellCorpopTres.addElement(cellNull.getPhrase()); cellCorpopTres.addElement(pCorpoTres9); cellCorpopTres.addElement(pCorpoTres10); cellCorpopTres.addElement(cellNull.getPhrase()); cellCorpopTres.addElement(pCorpoTres11); cellCorpopTres.addElement(cellNull.getPhrase()); cellCorpopTres.addElement(pCorpoTres12); pTableCorpoTres.addCell(cellCorpopTres); PdfPTable pTableAssinaturaTitulo = new PdfPTable(1); PdfPTable pTableAssinatura = new PdfPTable(new float[] { 50f, 50f }); Paragraph pUK = new Paragraph("", fontCorpo); pUK.add(new Phrase("Assinaturas", fontCorpoN)); pUK.add(new Phrase("Signature", fontUK)); PdfPCell cellAssinatora = new PdfPCell(pUK); cellAssinatora.setBorder(0); cellAssinatora.setHorizontalAlignment(Element.ALIGN_CENTER); PdfPCell celllinha1 = new PdfPCell( new Phrase("___________________________________".toUpperCase(), fontCorpo)); celllinha1.setBorder(0); celllinha1.setHorizontalAlignment(Element.ALIGN_CENTER); PdfPCell celllinha2 = new PdfPCell( new Phrase("___________________________________".toUpperCase(), fontCorpo)); celllinha2.setBorder(0); celllinha2.setHorizontalAlignment(Element.ALIGN_CENTER); pUK = new Paragraph("", fontCorpo); pUK.add(new Phrase("Pela NICON SEGUROS STP", fontCorpoN)); pUK.add(new Phrase("For NICON SEGUROS STP", fontUK)); PdfPCell celllinha11 = new PdfPCell(pUK); celllinha11.setBorder(0); celllinha11.setHorizontalAlignment(Element.ALIGN_CENTER); pUK = new Paragraph("", fontCorpo); pUK.add(new Phrase("O Segurado", fontCorpoN)); pUK.add(new Phrase("Insured", fontUK)); PdfPCell celllinha21 = new PdfPCell(pUK); celllinha21.setBorder(0); celllinha21.setHorizontalAlignment(Element.ALIGN_CENTER); pTableAssinaturaTitulo.addCell(cellAssinatora); pTableAssinatura.addCell(celllinha1); pTableAssinatura.addCell(celllinha2); pTableAssinatura.addCell(celllinha11); pTableAssinatura.addCell(celllinha21); Document documento = new Document(); documento.setPageSize(PageSize.A4); documento.setMargins(20f, 20f, 35f, 5f); File f = new File(arquivo + "/" + user + "/Seguro Carga Maritima/"); f.mkdirs(); String Ddata = sdf.format(new Date()); f = new File(f.getAbsoluteFile() + "/" + "Certificado Carga Maritima " + Ddata + ".pdf"); reString = "../Documentos/" + user + "/Seguro Carga Maritima/" + "Certificado Carga Maritima " + Ddata + ".pdf"; OutputStream outputStraem = new FileOutputStream(f); PdfWriter writer = PdfWriter.getInstance(documento, outputStraem); if (MarcaDAgua.isSimulation) { MarcaDAgua.SimulacaoVertical v = new MarcaDAgua.SimulacaoVertical(); writer.setPageEvent(v); } if (MarcaDAgua.isCanceled) { MarcaDAgua.AnulacaoVertical v = new MarcaDAgua.AnulacaoVertical(); writer.setPageEvent(v); } documento.open(); documento.add(pTableEmpresaPricipal); documento.add(pTableNull); documento.add(pTableTitulo); documento.add(pTableNull); documento.add(pTableNull); documento.add(pTableCorpoUm); documento.add(pTableNull); documento.add(pTableCorpoDois); documento.add(pTableCorpoTres); documento.add(pTableNull); documento.add(pTableNull); documento.add(pTableAssinaturaTitulo); documento.add(pTableNull); documento.add(pTableNull); documento.add(pTableNull); documento.add(pTableAssinatura); documento.close(); // PrintPdf printPdf = new PrintPdf(f.getAbsolutePath(), f.getAbsolutePath(), 0, 595f,842f,"Enviar Para o OneNote 2013",1); // //PrintPdf printPdf = new PrintPdf(f.getAbsolutePath(), f.getAbsolutePath(), 0, 595f,842f,"Hewlett-Packard HP LaserJet P2035",1); // // printPdf.print(); } catch (BadElementException | IOException ex) { Logger.getLogger(SeguroAPG.class.getName()).log(Level.SEVERE, null, ex); } catch (DocumentException ex) { Logger.getLogger(SeguroAPG.class.getName()).log(Level.SEVERE, null, ex); } return reString; }