List of usage examples for com.itextpdf.text Paragraph setAlignment
public void setAlignment(int alignment)
From source file:com.pma.mpsr.export.PDFGenerator.java
/** * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse * response)/* w ww . j a v a 2 s.co m*/ */ @Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String mpsrID = request.getParameter("MPSR_ID"); if (null == mpsrID) return; MPSRProjectInfo basicInfo = MPSRProjectInfo.getInstance(mpsrID); MPSRExecutiveSummary exeSummary = MPSRExecutiveSummary.getInstance(mpsrID); MPSRStatusSummary statusSummary = MPSRStatusSummary.getInstance(mpsrID); MPSRFunctionPerformance funcPerform = MPSRFunctionPerformance.getInstance(mpsrID); MPSRCostPerformance costPerform = MPSRCostPerformance.getInstance(mpsrID); MPSRSchedulePerformance[] schedulePerform = MPSRSchedulePerformance.getInstance(mpsrID); MPSRSafety safety = MPSRSafety.getInstance(mpsrID); MPSRAuthorization auth = MPSRAuthorization.getInstance(mpsrID); MPSRBudget budget = MPSRBudget.getInstance(mpsrID); MPSRCostReport[] costRpt = MPSRCostReport.getInstance(mpsrID); MPSRSchedule schedule = MPSRSchedule.getInstance(mpsrID); MPSRMilestone[] milestones = MPSRMilestone.getInstance(mpsrID); MPSRLPE lpe = MPSRLPE.getInstance(mpsrID); MPSRInsidePlantDesign[] ipds = MPSRInsidePlantDesign.getInstance(mpsrID); MPSROutsidePlantDesign[] opds = MPSROutsidePlantDesign.getInstance(mpsrID); MPSRProcure procure = MPSRProcure.getInstance(mpsrID); MPSRApprovedChanges[] approvedChanges = MPSRApprovedChanges.getInstance(mpsrID); MPSRPendingChanges[] pendingChanges = MPSRPendingChanges.getInstance(mpsrID); MPSRInsidePlantConstruction[] ipcs = MPSRInsidePlantConstruction.getInstance(mpsrID); MPSROutsidePlantConstruction[] opcs = MPSROutsidePlantConstruction.getInstance(mpsrID); MPSRAppendix[] appendixs = MPSRAppendix.getInstance(mpsrID); MPSRAttachment[] attachments = MPSRAttachment.getInstance(mpsrID); // response.setContentType("application/pdf"); // response.setHeader("Content-Disposition", // "attachment; filename=\"test.pdf\""); Font fontNormal = null; Font fontCoverTitle = new Font(FontFamily.HELVETICA, 20, Font.BOLD); Font fontCoverTableHeader = new Font(FontFamily.HELVETICA, 16, Font.BOLD); Font fontCoverTableContent = new Font(FontFamily.HELVETICA, 16); Font fontChapterHeader = new Font(FontFamily.HELVETICA, 18, Font.BOLD); Font fontSection1Header = new Font(FontFamily.HELVETICA, 16, Font.BOLD); Font fontSection2Header = new Font(FontFamily.HELVETICA, 14, Font.BOLD); Font fontWork = new Font(FontFamily.HELVETICA, 12, Font.UNDERLINE); Font fontTableCaption = new Font(FontFamily.TIMES_ROMAN, 12, Font.BOLD); Font fontTableColumnHeader = new Font(FontFamily.HELVETICA, 12, Font.BOLD); Font fontTableColumnHeaderYellow = new Font(FontFamily.HELVETICA, 12, Font.BOLD); fontTableColumnHeaderYellow.setColor(BaseColor.YELLOW); Font fontTableRowTitle = new Font(FontFamily.HELVETICA, 12, Font.ITALIC); Font fontTableCellBold = new Font(FontFamily.HELVETICA, 12, Font.BOLD); Font fontTableNote = new Font(FontFamily.HELVETICA, 10, Font.ITALIC); Font fontImageCaption = new Font(FontFamily.TIMES_ROMAN, 9, Font.BOLD); Font fontPOTableHeader = new Font(FontFamily.HELVETICA, 10, Font.BOLD); fontPOTableHeader.setColor(BaseColor.YELLOW); Font fontPOTable = new Font(FontFamily.HELVETICA, 9); Font fontPOTableSummary = new Font(FontFamily.HELVETICA, 9, Font.BOLD); Font fontPageHeader = new Font(FontFamily.HELVETICA, 8); Font fontPageFooter = new Font(FontFamily.HELVETICA, 10); Phrase[] headerTexts = new Phrase[] { new Phrase("PMA - ELECTRIC DELIVERY", fontPageHeader), new Phrase("DELIVERY PROJECTS & CONSTRUCTION (DP&C)", fontPageHeader), new Phrase("PROJECT MONTHLY REPORT", fontPageHeader) }; Paragraph paragraph = null; PdfPTable table = null; PdfPCell cell = null; Document document = new Document(DEFAULT_PAGE_SIZE, 36, 36, 9 * 10, 36); ByteArrayOutputStream baosOrig = new ByteArrayOutputStream(); XMLWorkerHelper xmlWorker = XMLWorkerHelper.getInstance(); try { PdfWriter writer = PdfWriter.getInstance(document, baosOrig); writer.setStrictImageSequence(true); writer.setLinearPageMode(); writer.setViewerPreferences(PdfWriter.PageModeUseOutlines | PdfWriter.FitWindow); Image icon = getEmbeddedImage(getServletContext(), "/resource/image/pma.bmp"); document.open(); PdfOutline root = writer.getRootOutline(); // *******************************************************************************************// // addOutline(root, writer, MPSRUI.TREE_0); for (int i = 0; i < 2; i++) { document.add(new Paragraph(" ")); } String[] titles = { "PMA DELIVERY PROJECTS & CONSTRUCTION", "MONTHLY REPORT", basicInfo.getReportMonthYear(), basicInfo.getProjectTitle(), "PROJECT No. " + basicInfo.getProjectDefinition() }; int[] spaceingAfters = { 48, 48, 48, 24, 48 }; for (int i = 0; i < titles.length; i++) { paragraph = new Paragraph(); paragraph.setSpacingAfter(spaceingAfters[i]); paragraph.setFont(fontCoverTitle); paragraph.setAlignment(Element.ALIGN_CENTER); paragraph.add(new Chunk(titles[i])); document.add(paragraph); } addCoverImage(document, MPSRUI.getFilePath(mpsrID, basicInfo.getFileName())); document.add(new Paragraph(" ")); table = new PdfPTable(2); table.addCell(new Phrase("Client", fontCoverTableHeader)); table.addCell(new Phrase(basicInfo.getProjectManager(), fontCoverTableContent)); table.addCell(new Phrase("Location", fontCoverTableHeader)); table.addCell(new Phrase(basicInfo.getProjectDirector(), fontCoverTableContent)); document.add(table); // *******************************************************************************************// document.resetPageCount(); document.add(Chunk.NEXTPAGE); writer.setPageEvent(new MPSRPageEventHelper(icon, headerTexts, fontPageFooter)); // *******************************************************************************************// PdfOutline outline1 = addOutline(root, writer, MPSRUI.TREE_1); addSectionTitle(document, MPSRUI.TREE_1, fontChapterHeader, 0, 0, 12); PdfOutline outline2 = addOutline(outline1, writer, "1.1"); addOutline(outline2, writer, MPSRUI.TREE_1_1_1); addSectionTitle(document, MPSRUI.TREE_1_1_1, fontSection2Header, 12, 12, 0); addParagraph(document, writer, xmlWorker, exeSummary.getDesc_1_1_1(), fontNormal, 12, 0, 12); addOutline(outline2, writer, MPSRUI.TREE_1_1_2); addSectionTitle(document, MPSRUI.TREE_1_1_2, fontSection2Header, 12, 12, 0); addParagraph(document, writer, xmlWorker, exeSummary.getDesc_1_1_2(), fontNormal, 12, 0, 12); addOutline(outline2, writer, MPSRUI.TREE_1_1_3); addSectionTitle(document, MPSRUI.TREE_1_1_3, fontSection2Header, 12, 12, 0); addParagraph(document, writer, xmlWorker, exeSummary.getDesc_1_1_3(), fontNormal, 12, 0, 12); addOutline(outline2, writer, MPSRUI.TREE_1_1_4); addSectionTitle(document, MPSRUI.TREE_1_1_4, fontSection2Header, 12, 12, 0); addParagraph(document, writer, xmlWorker, exeSummary.getDesc_1_1_4(), fontNormal, 12, 0, 12); // *******************************************************************************************// // 1.2 Status Summary // *******************************************************************************************// outline2 = addOutline(outline1, writer, MPSRUI.TREE_1_2); addSectionTitle(document, MPSRUI.TREE_1_2, fontSection1Header, 6, 12, 12); paragraph = new Paragraph(); paragraph.add(basicInfo.getProjectTitle()); paragraph.setSpacingAfter(4); document.add(paragraph); table = new PdfPTable(5); table.setTotalWidth(500); table.setLockedWidth(true); table.setWidths(new int[] { 3, 1, 1, 1, 1 }); cell = new PdfPCell( new Phrase("Project #: " + basicInfo.getProjectDefinition(), fontTableColumnHeader)); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); String[] headers = { "Status", "Approved (Include RnC)", "To Date", "At Completion" }; for (String header : headers) { cell = new PdfPCell(new Phrase(header, fontTableColumnHeader)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); } String[][] cellValues = { { "Budget ($M)", statusSummary.getBudgetStatus(), !"".equals(statusSummary.getBudgetApproved()) ? CURRENCY_FORMATTER .format(Double.parseDouble(statusSummary.getBudgetApproved())) : "", !"".equals(statusSummary.getBudgetToDate()) ? CURRENCY_FORMATTER.format(Double.parseDouble(statusSummary.getBudgetToDate())) : "", !"".equals(statusSummary.getBudgetAtCompletion()) ? CURRENCY_FORMATTER .format(Double.parseDouble(statusSummary.getBudgetAtCompletion())) : "" }, { "Schedule - Duration (months)", statusSummary.getScheduleStatus(), statusSummary.getScheduleApproved(), statusSummary.getScheduleToDate(), statusSummary.getScheduleAtCompletion() }, { "In-Service Date", statusSummary.getInServiceDateStatus(), statusSummary.getInServiceDateApproved(), statusSummary.getInServiceDateToDate(), statusSummary.getInServiceDateAtCompletion() } }; for (int i = 0; i < cellValues.length; i++) { table.addCell(new Phrase(cellValues[i][0])); cell = new PdfPCell(new Phrase(cellValues[i][1])); cell.setBackgroundColor(getBackgroundColor(cellValues[i][1])); cell.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(cell); for (int j = 2; j < 5; j++) { cell = new PdfPCell(new Phrase(cellValues[i][j])); cell.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(cell); } } document.add(table); // -------------------------------------------------------------------// paragraph = new Paragraph("Legend:"); paragraph.setSpacingAfter(4); paragraph.setIndentationLeft(25); document.add(paragraph); table = new PdfPTable(3); table.setTotalWidth(240); table.setLockedWidth(true); table.setHorizontalAlignment(Element.ALIGN_LEFT); String[] legends = { "On Target", "At Risk", "Off Target" }; for (String legend : legends) { cell = new PdfPCell(new Phrase(legend)); cell.setBackgroundColor(getBackgroundColor(legend)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); cell.setMinimumHeight(18); cell.setPadding(0); table.addCell(cell); } paragraph = new Paragraph(); paragraph.add(table); paragraph.setIndentationLeft(25); document.add(paragraph); // *******************************************************************************************// // 1.2.1 Functional Area Performance Indicators // *******************************************************************************************// addOutline(outline2, writer, MPSRUI.TREE_1_2_1); addSectionTitle(document, MPSRUI.TREE_1_2_1, fontSection2Header, 12, 12, 12); table = new PdfPTable(4); table.setTotalWidth(550); table.setLockedWidth(true); table.setWidths(new int[] { 4, 1, 1, 4 }); headers = new String[] { "Activities", "Current Status", "Trend", "Comments (main performance drives)" }; for (String header : headers) { cell = new PdfPCell(new Phrase(header, fontTableColumnHeader)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); } Image imgArrowUp = getEmbeddedImage(getServletContext(), "/VAADIN/themes/MPSR/img/Arrow_Up.png"); Image imgArrowDown = getEmbeddedImage(getServletContext(), "/VAADIN/themes/MPSR/img/Arrow_Down.png"); Image imgArrowEven = getEmbeddedImage(getServletContext(), "/VAADIN/themes/MPSR/img/Arrow_Even.png"); Image[] images = { imgArrowUp, imgArrowDown, imgArrowEven }; for (Image image : images) { image.scaleToFit(12, 12); } cellValues = new String[][] { { "Project - " + basicInfo.getProjectTitle(), funcPerform.getProjectStatus(), funcPerform.getProjectTrend(), funcPerform.getProjectComment() }, { " Target Budget", funcPerform.getTargetBudgetStatus(), funcPerform.getTargetBudgetTrend(), funcPerform.getTargetBudgetComment() }, { " Safety", funcPerform.getSafetyStatus(), funcPerform.getSafetyTrend(), funcPerform.getSafetyComment() }, { " Licensing & Permitting", funcPerform.getLicensingStatus(), funcPerform.getLicensingTrend(), funcPerform.getLicensingComment() }, { " Corporate Properties", funcPerform.getCorporateStatus(), funcPerform.getCorporateTrend(), funcPerform.getCorporateComment() }, { " Inside Plant Design & Engineering", funcPerform.getIPDEStatus(), funcPerform.getIPDETrend(), funcPerform.getIPDEComment() }, { " Public Outreach", funcPerform.getOutreachStatus(), funcPerform.getOutreachTrend(), funcPerform.getOutreachComment() }, { " Procurement", funcPerform.getProcureStatus(), funcPerform.getProcureTrend(), funcPerform.getProcureComment() }, { " Construction", funcPerform.getConstructionStatus(), funcPerform.getConstructionTrend(), funcPerform.getConstructionComment() }, { " Environmental - Resource Recovery", funcPerform.getEnviromentStatus(), funcPerform.getEnviromentTrend(), funcPerform.getEnviromentComment() }, { " Salvage", funcPerform.getSalvageStatus(), funcPerform.getSalvageTrend(), funcPerform.getSalvageComment() }, { " Withdrawal", funcPerform.getWithdrawalStatus(), funcPerform.getWithdrawalTrend(), funcPerform.getWithdrawalComment() } }; for (int i = 0; i < cellValues.length; i++) { cell = new PdfPCell(new Phrase(cellValues[i][0])); cell.setHorizontalAlignment(Element.ALIGN_LEFT); table.addCell(cell); cell = new PdfPCell(new Phrase(cellValues[i][1])); cell.setBackgroundColor(getBackgroundColor(cellValues[i][1])); cell.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(cell); if ("Up".equals(cellValues[i][2])) { cell = new PdfPCell(imgArrowUp); } else if ("Down".equals(cellValues[i][2])) { cell = new PdfPCell(imgArrowDown); } else if ("Even".equals(cellValues[i][2])) { cell = new PdfPCell(imgArrowEven); } else { cell = new PdfPCell(); } cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); cell = new PdfPCell(new Phrase(cellValues[i][3])); cell.setHorizontalAlignment(Element.ALIGN_LEFT); table.addCell(cell); } document.add(table); // *******************************************************************************************// document.setPageSize(DEFAULT_PAGE_SIZE.rotate()); document.add(Chunk.NEXTPAGE); addOutline(outline2, writer, MPSRUI.TREE_1_2_2); addSectionTitle(document, MPSRUI.TREE_1_2_2, fontSection2Header, 12, 12, 12); addImage(document, MPSRUI.getFilePath(mpsrID, costPerform.getFileName())); // *******************************************************************************************// // 1.2.3 Schedule Performance // *******************************************************************************************// document.add(Chunk.NEXTPAGE); addOutline(outline2, writer, MPSRUI.TREE_1_2_3); addSectionTitle(document, MPSRUI.TREE_1_2_3, fontSection2Header, 12, 12, 12); table = new PdfPTable(9); table.setTotalWidth(750); table.setLockedWidth(true); table.setWidths(new int[] { 3, 1, 1, 1, 1, 1, 1, 1, 1 }); table.setHorizontalAlignment(Element.ALIGN_CENTER); headers = new String[] { "WBS", "Original Duration", "Remaining Duration", "Baseline Start Date", "Baseline Finish Date", "Start Date", "Finish Date", "Total Float", "Status" }; for (String header : headers) { cell = new PdfPCell(new Phrase(header, fontTableColumnHeaderYellow)); cell.setBackgroundColor(BaseColor.BLUE); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); } for (int i = 0; i < schedulePerform.length; i++) { cell = new PdfPCell(new Phrase(schedulePerform[i].getWBS())); cell.setHorizontalAlignment(Element.ALIGN_LEFT); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); cell = new PdfPCell(new Phrase(Double.toString(schedulePerform[i].getOriginalDuration()))); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); cell = new PdfPCell(new Phrase(Double.toString(schedulePerform[i].getRemainingDuration()))); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); cell = new PdfPCell(new Phrase(schedulePerform[i].getPlannedStartDate())); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); cell = new PdfPCell(new Phrase(schedulePerform[i].getPlannedFinishDate())); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); cell = new PdfPCell(new Phrase(schedulePerform[i].getStartDate())); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); cell = new PdfPCell(new Phrase(schedulePerform[i].getFinishDate())); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); cell = new PdfPCell(new Phrase(schedulePerform[i].getTotalFloat())); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); cell = new PdfPCell(new Phrase(schedulePerform[i].getStatus())); cell.setHorizontalAlignment(Element.ALIGN_LEFT); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); } table.setHeaderRows(1); document.add(table); // *******************************************************************************************// // 1.3 Project Change Control // *******************************************************************************************// document.setPageSize(DEFAULT_PAGE_SIZE); document.add(Chunk.NEXTPAGE); outline2 = addOutline(outline1, writer, MPSRUI.TREE_1_3); addSectionTitle(document, MPSRUI.TREE_1_3, fontSection1Header, 6, 12, 12); addOutline(outline2, writer, MPSRUI.TREE_1_3_1); addSectionTitle(document, MPSRUI.TREE_1_3_1, fontSection2Header, 12, 12, 0); addParagraph(document, writer, xmlWorker, exeSummary.getDesc_1_3_1(), fontNormal, 12, 0, 12); addOutline(outline2, writer, MPSRUI.TREE_1_3_2); addSectionTitle(document, MPSRUI.TREE_1_3_2, fontSection2Header, 12, 12, 0); addParagraph(document, writer, xmlWorker, exeSummary.getDesc_1_3_2(), fontNormal, 12, 0, 12); // *******************************************************************************************// // 2 Safety // *******************************************************************************************// addOutline(root, writer, MPSRUI.TREE_2); addSectionTitle(document, MPSRUI.TREE_2, fontChapterHeader, 0, 24, 12); addParagraph(document, writer, xmlWorker, safety.getDesc1(), fontNormal, 12, 0, 12); paragraph = new Paragraph("Table 2.1 Project Safety Summary", fontTableCaption); paragraph.setAlignment(Element.ALIGN_CENTER); paragraph.setSpacingAfter(6); document.add(paragraph); table = new PdfPTable(3); table.setTotalWidth(300); table.setLockedWidth(true); table.setWidths(new int[] { 1, 1, 1 }); table.setHorizontalAlignment(Element.ALIGN_RIGHT); cell = new PdfPCell(new Phrase("Total Work Hours", fontTableColumnHeaderYellow)); cell.setColspan(3); cell.setBackgroundColor(BaseColor.BLUE); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); headers = new String[] { "Current Period", "Calendar YTD", "Project To Date" }; for (String header : headers) { cell = new PdfPCell(new Phrase(header, fontTableColumnHeader)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); } cellValues = new String[][] { { INTEGER_FORMATTER.format(safety.getTotalWorkHoursCurrent()), INTEGER_FORMATTER.format(safety.getTotalWorkHoursYTD()), INTEGER_FORMATTER.format(safety.getTotalWorkHoursPTD()) } }; for (int i = 0; i < cellValues.length; i++) { cell = new PdfPCell(new Phrase(cellValues[i][0])); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); cell = new PdfPCell(new Phrase(cellValues[i][1])); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); cell = new PdfPCell(new Phrase(cellValues[i][2], fontTableCellBold)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); } document.add(table); // ----------------------------------- table = new PdfPTable(4); table.setTotalWidth(500); table.setLockedWidth(true); table.setWidths(new int[] { 2, 1, 1, 1 }); table.setHorizontalAlignment(Element.ALIGN_RIGHT); cell = new PdfPCell(new Phrase("Incidents", fontTableColumnHeaderYellow)); cell.setColspan(4); cell.setBackgroundColor(BaseColor.BLUE); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); cellValues = new String[][] { { "OSHA Recordable", INTEGER_FORMATTER.format(safety.getOshaRecordableCurrent()), INTEGER_FORMATTER.format(safety.getOshaRecordableYTD()), INTEGER_FORMATTER.format(safety.getOshaRecordablePTD()) }, { "First Aid", INTEGER_FORMATTER.format(safety.getFirstAid1Current()), INTEGER_FORMATTER.format(safety.getFirstAid1YTD()), INTEGER_FORMATTER.format(safety.getFirstAid1PTD()) }, { "Near Miss", INTEGER_FORMATTER.format(safety.getNearMissCurrent()), INTEGER_FORMATTER.format(safety.getNearMissYTD()), INTEGER_FORMATTER.format(safety.getNearMissPTD()) }, { "First Aid", INTEGER_FORMATTER.format(safety.getFirstAid2Current()), INTEGER_FORMATTER.format(safety.getFirstAid2YTD()), INTEGER_FORMATTER.format(safety.getFirstAid2PTD()) } }; for (int i = 0; i < cellValues.length; i++) { cell = new PdfPCell(new Phrase(cellValues[i][0], fontTableRowTitle)); cell.setHorizontalAlignment(Element.ALIGN_LEFT); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); cell = new PdfPCell(new Phrase(cellValues[i][1])); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); cell = new PdfPCell(new Phrase(cellValues[i][2])); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); cell = new PdfPCell(new Phrase(cellValues[i][3], fontTableCellBold)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); } cell = new PdfPCell(new Phrase("*Note - " + safety.getNote(), fontTableNote)); cell.setColspan(4); cell.setHorizontalAlignment(Element.ALIGN_LEFT); cell.setVerticalAlignment(Element.ALIGN_TOP); table.addCell(cell); document.add(table); // *******************************************************************************************// // 3 Project Authorization // *******************************************************************************************// addOutline(root, writer, MPSRUI.TREE_3); addSectionTitle(document, MPSRUI.TREE_3, fontChapterHeader, 0, 24, 12); addParagraph(document, writer, xmlWorker, auth.getDesc1(), fontNormal, 12, 0, 12); table = new PdfPTable(10); table.setSpacingBefore(6); table.setTotalWidth(550); table.setLockedWidth(true); table.setWidths(new int[] { 3, 1, 1, 1, 1, 1, 1, 2, 1, 1 }); table.setHorizontalAlignment(Element.ALIGN_CENTER); headers = new String[] { "$ Millions", "Prior", auth.getHeaderYear0(), auth.getHeaderYear1(), auth.getHeaderYear2(), auth.getHeaderYear3(), auth.getHeaderYear4(), auth.getHeaderPostYear(), "Total", "Auth" }; for (String header : headers) { cell = new PdfPCell(new Phrase(header, fontTableColumnHeader)); cell.setBackgroundColor(BaseColor.YELLOW); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); } cellValues = new String[][] { { "Base", NUMBER_FORMATTER.format(auth.getBasePriorYear()), NUMBER_FORMATTER.format(auth.getBaseYear0()), NUMBER_FORMATTER.format(auth.getBaseYear1()), NUMBER_FORMATTER.format(auth.getBaseYear2()), NUMBER_FORMATTER.format(auth.getBaseYear3()), NUMBER_FORMATTER.format(auth.getBaseYear4()), NUMBER_FORMATTER.format(auth.getBasePostYear()), NUMBER_FORMATTER.format(auth.getBaseTotal()), "" }, { "Risk & Contingency", NUMBER_FORMATTER.format(auth.getRnCPriorYear()), NUMBER_FORMATTER.format(auth.getRnCYear0()), NUMBER_FORMATTER.format(auth.getRnCYear1()), NUMBER_FORMATTER.format(auth.getRnCYear2()), NUMBER_FORMATTER.format(auth.getRnCYear3()), NUMBER_FORMATTER.format(auth.getRnCYear4()), NUMBER_FORMATTER.format(auth.getRnCPostYear()), NUMBER_FORMATTER.format(auth.getRnCTotal()), "" }, { "Total Project " + auth.getTotalProjectDate(), NUMBER_FORMATTER.format(auth.getPriorTotal()), NUMBER_FORMATTER.format(auth.getYear0Total()), NUMBER_FORMATTER.format(auth.getYear1Total()), NUMBER_FORMATTER.format(auth.getYear2Total()), NUMBER_FORMATTER.format(auth.getYear3Total()), NUMBER_FORMATTER.format(auth.getYear4Total()), NUMBER_FORMATTER.format(auth.getPostTotal()), NUMBER_FORMATTER.format(auth.getTotalTotal()), "" }, { "Current Request " + auth.getReq0RequestDate(), NUMBER_FORMATTER.format(auth.getReq0PriorYear()), NUMBER_FORMATTER.format(auth.getReq0Year0()), NUMBER_FORMATTER.format(auth.getReq0Year1()), NUMBER_FORMATTER.format(auth.getReq0Year2()), NUMBER_FORMATTER.format(auth.getReq0Year3()), NUMBER_FORMATTER.format(auth.getReq0Year4()), NUMBER_FORMATTER.format(auth.getReq0PostYear()), NUMBER_FORMATTER.format(auth.getReq0Total()), NUMBER_FORMATTER.format(auth.getReq0Authorization()) }, { "Request Date " + auth.getReq1RequestDate(), NUMBER_FORMATTER.format(auth.getReq1PriorYear()), NUMBER_FORMATTER.format(auth.getReq1Year0()), NUMBER_FORMATTER.format(auth.getReq1Year1()), NUMBER_FORMATTER.format(auth.getReq1Year2()), NUMBER_FORMATTER.format(auth.getReq1Year3()), NUMBER_FORMATTER.format(auth.getReq1Year4()), NUMBER_FORMATTER.format(auth.getReq1PostYear()), NUMBER_FORMATTER.format(auth.getReq1Total()), NUMBER_FORMATTER.format(auth.getReq1Authorization()) }, { "Request Date " + auth.getReq2RequestDate(), NUMBER_FORMATTER.format(auth.getReq2PriorYear()), NUMBER_FORMATTER.format(auth.getReq2Year0()), NUMBER_FORMATTER.format(auth.getReq2Year1()), NUMBER_FORMATTER.format(auth.getReq2Year2()), NUMBER_FORMATTER.format(auth.getReq2Year3()), NUMBER_FORMATTER.format(auth.getReq2Year4()), NUMBER_FORMATTER.format(auth.getReq2PostYear()), NUMBER_FORMATTER.format(auth.getReq2Total()), NUMBER_FORMATTER.format(auth.getReq2Authorization()) }, { "Target Budget", "", "", "", "", "", "", "", auth.getTargetBudget(), "" } }; for (int i = 0; i < cellValues.length; i++) { cell = new PdfPCell(new Phrase(cellValues[i][0])); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); for (int j = 1; j < cellValues[i].length; j++) { cell = new PdfPCell(new Phrase(cellValues[i][j])); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); } } document.add(table); // *******************************************************************************************// // 4 Project Budget // *******************************************************************************************// addOutline(root, writer, MPSRUI.TREE_4); addSectionTitle(document, MPSRUI.TREE_4, fontChapterHeader, 0, 24, 12); addParagraph(document, writer, xmlWorker, budget.getDesc1(), fontNormal, 12, 0, 12); table = new PdfPTable(2); table.setSpacingBefore(6); table.setTotalWidth(350); table.setLockedWidth(true); table.setWidths(new int[] { 5, 2 }); table.setHorizontalAlignment(Element.ALIGN_CENTER); cellValues = new String[][] { { "Current Approved Budget (Base + RnC)", CURRENCY_FORMATTER.format(budget.getPMBudget()) + "M" }, { "Approved Phase Funding", CURRENCY_FORMATTER.format(budget.getPMActual()) + "M" }, { "Expended To Date", CURRENCY_FORMATTER.format(budget.getPMCommitment()) + "M" }, { "At Completion", CURRENCY_FORMATTER.format(budget.getPMAdditionalCost()) + "M" } }; for (int i = 0; i < cellValues.length; i++) { cell = new PdfPCell(new Phrase(cellValues[i][0])); cell.setHorizontalAlignment(Element.ALIGN_LEFT); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); cell = new PdfPCell(new Phrase(cellValues[i][1])); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); } document.add(table); // ---------------------------------------------------- // table 4.1 // ---------------------------------------------------- paragraph = new Paragraph("Table 4.1 Cost Report Summary", fontTableCaption); paragraph.setAlignment(Element.ALIGN_CENTER); paragraph.setSpacingAfter(6); document.add(paragraph); table = new PdfPTable(5); table.setTotalWidth(500); table.setLockedWidth(true); table.setWidths(new int[] { 1, 1, 1, 1, 1 }); table.setHorizontalAlignment(Element.ALIGN_CENTER); headers = new String[] { "Work Element", "Description", "Estimate", "Actual", "EAC" }; for (String header : headers) { cell = new PdfPCell(new Phrase(header, fontTableColumnHeaderYellow)); cell.setBackgroundColor(BaseColor.BLUE); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); } for (int i = 0; i < costRpt.length; i++) { cell = new PdfPCell(new Phrase(costRpt[i].getWbs())); cell.setHorizontalAlignment(Element.ALIGN_LEFT); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); cell = new PdfPCell(new Phrase(costRpt[i].getWbsDesc())); cell.setHorizontalAlignment(Element.ALIGN_LEFT); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); cell = new PdfPCell(new Phrase(formatNumberString(costRpt[i].getEstimate()))); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); cell = new PdfPCell(new Phrase(formatNumberString(costRpt[i].getActual()))); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); cell = new PdfPCell(new Phrase(formatNumberString(costRpt[i].getEAC()))); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); } document.add(table); // *******************************************************************************************// // 5 Project Schedule // *******************************************************************************************// outline1 = addOutline(root, writer, MPSRUI.TREE_5); addSectionTitle(document, MPSRUI.TREE_5, fontChapterHeader, 0, 24, 12); addOutline(outline1, writer, MPSRUI.TREE_5_1); addSectionTitle(document, MPSRUI.TREE_5_1, fontSection1Header, 6, 12, 12); addParagraph(document, writer, xmlWorker, schedule.getDesc_5_1(), fontNormal, 12, 0, 12); addOutline(outline1, writer, MPSRUI.TREE_5_2); addSectionTitle(document, MPSRUI.TREE_5_2, fontSection1Header, 6, 12, 12); addParagraph(document, writer, xmlWorker, schedule.getDesc_5_2(), fontNormal, 12, 0, 12); addOutline(outline1, writer, MPSRUI.TREE_5_3); addSectionTitle(document, MPSRUI.TREE_5_3, fontSection1Header, 6, 12, 12); addParagraph(document, writer, xmlWorker, schedule.getDesc_5_3(), fontNormal, 12, 0, 12); addOutline(outline1, writer, MPSRUI.TREE_5_4); addSectionTitle(document, MPSRUI.TREE_5_4, fontSection1Header, 6, 12, 12); addParagraph(document, writer, xmlWorker, schedule.getDesc_5_4(), fontNormal, 12, 0, 12); // ---------------------------------------------------- // table 5.1 // ---------------------------------------------------- paragraph = new Paragraph("Table 5.1 Planned Scorecard Milestones", fontTableCaption); paragraph.setAlignment(Element.ALIGN_CENTER); paragraph.setSpacingAfter(6); document.add(paragraph); table = new PdfPTable(3); table.setTotalWidth(500); table.setLockedWidth(true); table.setWidths(new int[] { 3, 1, 1 }); table.setHorizontalAlignment(Element.ALIGN_CENTER); headers = new String[] { "Milestone", "Planned Date", "Finish Date" }; for (String header : headers) { cell = new PdfPCell(new Phrase(header, fontTableColumnHeaderYellow)); cell.setBackgroundColor(BaseColor.BLUE); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); } for (int i = 0; i < milestones.length; i++) { cell = new PdfPCell(new Phrase(milestones[i].getMilestone())); cell.setHorizontalAlignment(Element.ALIGN_LEFT); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); cell = new PdfPCell(new Phrase(milestones[i].getPlannedDate())); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); cell = new PdfPCell(new Phrase(milestones[i].getFinishDate())); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); } document.add(table); // *******************************************************************************************// // 6 License & Permitting, and Environmental Status // *******************************************************************************************// outline1 = addOutline(root, writer, MPSRUI.TREE_6); addSectionTitle(document, MPSRUI.TREE_6, fontChapterHeader, 0, 24, 12); addOutline(outline1, writer, MPSRUI.TREE_6_1); addSectionTitle(document, MPSRUI.TREE_6_1, fontSection1Header, 6, 12, 12); addParagraph(document, writer, xmlWorker, lpe.getDesc_6_1(), fontNormal, 12, 0, 12); outline2 = addOutline(outline1, writer, MPSRUI.TREE_6_2); addSectionTitle(document, MPSRUI.TREE_6_2, fontSection1Header, 6, 12, 12); addOutline(outline2, writer, MPSRUI.TREE_6_2_1); addSectionTitle(document, MPSRUI.TREE_6_2_1, fontSection2Header, 12, 12, 12); addParagraph(document, writer, xmlWorker, lpe.getDesc_6_2_1(), fontNormal, 12, 0, 12); addOutline(outline2, writer, MPSRUI.TREE_6_2_2); addSectionTitle(document, MPSRUI.TREE_6_2_2, fontSection2Header, 12, 12, 12); addParagraph(document, writer, xmlWorker, lpe.getDesc_6_2_2(), fontNormal, 12, 0, 12); // *******************************************************************************************// // 7 Engineering Status // *******************************************************************************************// outline1 = addOutline(root, writer, MPSRUI.TREE_7); addSectionTitle(document, MPSRUI.TREE_7, fontChapterHeader, 0, 24, 12); addOutline(outline1, writer, MPSRUI.TREE_7_1); addSectionTitle(document, MPSRUI.TREE_7_1, fontSection1Header, 6, 12, 12); table = new PdfPTable(5); table.setTotalWidth(500); table.setLockedWidth(true); table.setWidths(new int[] { 2, 1, 1, 1, 3 }); table.setHorizontalAlignment(Element.ALIGN_CENTER); headers = new String[] { "Package", "IFR", "IFC", "Indicator", "Note" }; for (String header : headers) { cell = new PdfPCell(new Phrase(header, fontTableColumnHeaderYellow)); cell.setBackgroundColor(BaseColor.BLUE); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); } for (int i = 0; i < ipds.length; i++) { cell = new PdfPCell(new Phrase(ipds[i].getPackage())); cell.setHorizontalAlignment(Element.ALIGN_LEFT); cell.setVerticalAlignment(Element.ALIGN_TOP); table.addCell(cell); cell = new PdfPCell(new Phrase(ipds[i].getIFR())); cell.setHorizontalAlignment(Element.ALIGN_LEFT); cell.setVerticalAlignment(Element.ALIGN_TOP); table.addCell(cell); cell = new PdfPCell(new Phrase(ipds[i].getIFC())); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); cell.setVerticalAlignment(Element.ALIGN_TOP); table.addCell(cell); cell = new PdfPCell(new Phrase(ipds[i].getIndicator())); cell.setBackgroundColor(getBackgroundColor(ipds[i].getIndicator())); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_TOP); table.addCell(cell); cell = new PdfPCell(new Phrase(ipds[i].getNote())); cell.setHorizontalAlignment(Element.ALIGN_LEFT); cell.setVerticalAlignment(Element.ALIGN_TOP); table.addCell(cell); } document.add(table); // -----------------------------------------------------------------------------------// addOutline(outline1, writer, MPSRUI.TREE_7_2); addSectionTitle(document, MPSRUI.TREE_7_2, fontSection1Header, 6, 12, 12); table = new PdfPTable(5); table.setTotalWidth(500); table.setLockedWidth(true); table.setWidths(new int[] { 2, 1, 1, 1, 3 }); table.setHorizontalAlignment(Element.ALIGN_CENTER); headers = new String[] { "Package", "IFR", "IFC", "Indicator", "Note" }; for (String header : headers) { cell = new PdfPCell(new Phrase(header, fontTableColumnHeaderYellow)); cell.setBackgroundColor(BaseColor.BLUE); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); } for (int i = 0; i < opds.length; i++) { cell = new PdfPCell(new Phrase(opds[i].getPackage())); cell.setHorizontalAlignment(Element.ALIGN_LEFT); cell.setVerticalAlignment(Element.ALIGN_TOP); table.addCell(cell); cell = new PdfPCell(new Phrase(opds[i].getIFR())); cell.setHorizontalAlignment(Element.ALIGN_LEFT); cell.setVerticalAlignment(Element.ALIGN_TOP); table.addCell(cell); cell = new PdfPCell(new Phrase(opds[i].getIFC())); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); cell.setVerticalAlignment(Element.ALIGN_TOP); table.addCell(cell); cell = new PdfPCell(new Phrase(opds[i].getIndicator())); cell.setBackgroundColor(getBackgroundColor(opds[i].getIndicator())); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_TOP); table.addCell(cell); cell = new PdfPCell(new Phrase(opds[i].getNote())); cell.setHorizontalAlignment(Element.ALIGN_LEFT); cell.setVerticalAlignment(Element.ALIGN_TOP); table.addCell(cell); } document.add(table); // *******************************************************************************************// // 8 Procurement Status // *******************************************************************************************// outline1 = addOutline(root, writer, MPSRUI.TREE_8); addSectionTitle(document, MPSRUI.TREE_8, fontChapterHeader, 0, 24, 12); outline2 = addOutline(outline1, writer, MPSRUI.TREE_8_1); addSectionTitle(document, MPSRUI.TREE_8_1, fontSection1Header, 6, 12, 12); table = new PdfPTable(2); table.setTotalWidth(300); table.setLockedWidth(true); table.setWidths(new int[] { 1, 1 }); table.setHorizontalAlignment(Element.ALIGN_CENTER); cellValues = new String[][] { { "Receipted to Date", CURRENCY_FORMATTER.format(procure.getReceiptedToDate()) }, { "Open Commitments", CURRENCY_FORMATTER.format(procure.getOpenCommitment()) }, { "Total", CURRENCY_FORMATTER.format(procure.getTotalPurchaseOrder()) } }; for (int i = 0; i < cellValues.length; i++) { cell = new PdfPCell(new Phrase(cellValues[i][0])); cell.setHorizontalAlignment(Element.ALIGN_LEFT); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); cell = new PdfPCell(new Phrase(cellValues[i][1])); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); } document.add(table); addParagraph(document, writer, xmlWorker, procure.getDesc_8_1_B(), fontNormal, 12, 12, 12); outline2 = addOutline(outline1, writer, MPSRUI.TREE_8_2); addSectionTitle(document, MPSRUI.TREE_8_2, fontSection1Header, 6, 12, 12); // ---------------------------------------------------- // section 8.2.1 // ---------------------------------------------------- addOutline(outline2, writer, MPSRUI.TREE_8_2_1); addSectionTitle(document, MPSRUI.TREE_8_2_1, fontSection2Header, 12, 12, 12); addParagraph(document, writer, xmlWorker, procure.getDesc_8_2_1(), fontNormal, 12, 0, 12); table = new PdfPTable(6); table.setTotalWidth(550); table.setLockedWidth(true); table.setWidths(new int[] { 1, 2, 1, 1, 2, 1 }); table.setHorizontalAlignment(Element.ALIGN_CENTER); headers = new String[] { "Purchase Order", "Vendor", "Previous Amount", "This Month Amount", "This Month Description", "Total Amount" }; for (String header : headers) { cell = new PdfPCell(new Phrase(header, fontPOTableHeader)); cell.setBackgroundColor(BaseColor.BLUE); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); } double totalToDate = 0; for (int i = 0; i < approvedChanges.length; i++) { cell = new PdfPCell(new Phrase(approvedChanges[i].getPurchaseOrder(), fontPOTable)); cell.setHorizontalAlignment(Element.ALIGN_LEFT); cell.setVerticalAlignment(Element.ALIGN_TOP); table.addCell(cell); cell = new PdfPCell(new Phrase(approvedChanges[i].getVendor(), fontPOTable)); cell.setHorizontalAlignment(Element.ALIGN_LEFT); cell.setVerticalAlignment(Element.ALIGN_TOP); table.addCell(cell); cell = new PdfPCell( new Phrase(CURRENCY_FORMATTER.format(approvedChanges[i].getPreviousAmount()), fontPOTable)); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); cell.setVerticalAlignment(Element.ALIGN_TOP); table.addCell(cell); cell = new PdfPCell(new Phrase(CURRENCY_FORMATTER.format(approvedChanges[i].getThisMonthAmount()), fontPOTable)); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); cell.setVerticalAlignment(Element.ALIGN_TOP); table.addCell(cell); cell = new PdfPCell(new Phrase(approvedChanges[i].getThisMonthDescription(), fontPOTable)); cell.setHorizontalAlignment(Element.ALIGN_LEFT); cell.setVerticalAlignment(Element.ALIGN_TOP); table.addCell(cell); cell = new PdfPCell( new Phrase(CURRENCY_FORMATTER.format(approvedChanges[i].getTotalAmount()), fontPOTable)); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); cell.setVerticalAlignment(Element.ALIGN_TOP); table.addCell(cell); totalToDate += approvedChanges[i].getTotalAmount(); } document.add(table); table = new PdfPTable(2); table.setTotalWidth(550); table.setLockedWidth(true); table.setWidths(new int[] { 7, 1 }); table.setHorizontalAlignment(Element.ALIGN_CENTER); cell = new PdfPCell(new Phrase("Total To Date", fontPOTableSummary)); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); cell.setVerticalAlignment(Element.ALIGN_TOP); table.addCell(cell); cell = new PdfPCell(new Phrase(CURRENCY_FORMATTER.format(totalToDate), fontPOTableSummary)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_TOP); table.addCell(cell); document.add(table); // ---------------------------------------------------- // section 8.2.2 // ---------------------------------------------------- addOutline(outline2, writer, MPSRUI.TREE_8_2_2); addSectionTitle(document, MPSRUI.TREE_8_2_2, fontSection2Header, 12, 12, 12); addParagraph(document, writer, xmlWorker, procure.getDesc_8_2_2(), fontNormal, 12, 0, 12); table = new PdfPTable(6); table.setTotalWidth(550); table.setLockedWidth(true); table.setWidths(new int[] { 1, 2, 1, 1, 2, 1 }); table.setHorizontalAlignment(Element.ALIGN_CENTER); headers = new String[] { "Purchase Order", "Vendor", "Previous Amount", "This Month Amount", "This Month Description", "Total Amount" }; for (String header : headers) { cell = new PdfPCell(new Phrase(header, fontPOTableHeader)); cell.setBackgroundColor(BaseColor.BLUE); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); } totalToDate = 0; for (int i = 0; i < pendingChanges.length; i++) { cell = new PdfPCell(new Phrase(pendingChanges[i].getPurchaseOrder(), fontPOTable)); cell.setHorizontalAlignment(Element.ALIGN_LEFT); cell.setVerticalAlignment(Element.ALIGN_TOP); table.addCell(cell); cell = new PdfPCell(new Phrase(pendingChanges[i].getVendor(), fontPOTable)); cell.setHorizontalAlignment(Element.ALIGN_LEFT); cell.setVerticalAlignment(Element.ALIGN_TOP); table.addCell(cell); cell = new PdfPCell( new Phrase(CURRENCY_FORMATTER.format(pendingChanges[i].getPreviousAmount()), fontPOTable)); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); cell.setVerticalAlignment(Element.ALIGN_TOP); table.addCell(cell); cell = new PdfPCell( new Phrase(CURRENCY_FORMATTER.format(pendingChanges[i].getThisMonthAmount()), fontPOTable)); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); cell.setVerticalAlignment(Element.ALIGN_TOP); table.addCell(cell); cell = new PdfPCell(new Phrase(pendingChanges[i].getThisMonthDescription(), fontPOTable)); cell.setHorizontalAlignment(Element.ALIGN_LEFT); cell.setVerticalAlignment(Element.ALIGN_TOP); table.addCell(cell); cell = new PdfPCell( new Phrase(CURRENCY_FORMATTER.format(pendingChanges[i].getTotalAmount()), fontPOTable)); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); cell.setVerticalAlignment(Element.ALIGN_TOP); table.addCell(cell); totalToDate += pendingChanges[i].getTotalAmount(); } document.add(table); table = new PdfPTable(2); table.setTotalWidth(550); table.setLockedWidth(true); table.setWidths(new int[] { 7, 1 }); table.setHorizontalAlignment(Element.ALIGN_CENTER); cell = new PdfPCell(new Phrase("Total To Date", fontPOTableSummary)); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); cell.setVerticalAlignment(Element.ALIGN_TOP); table.addCell(cell); cell = new PdfPCell(new Phrase(CURRENCY_FORMATTER.format(totalToDate), fontPOTableSummary)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_TOP); table.addCell(cell); document.add(table); // *******************************************************************************************// // 9 Construction Status // *******************************************************************************************// outline1 = addOutline(root, writer, MPSRUI.TREE_9); addSectionTitle(document, MPSRUI.TREE_9, fontChapterHeader, 0, 24, 12); addOutline(outline1, writer, MPSRUI.TREE_9_1); addSectionTitle(document, MPSRUI.TREE_9_1, fontSection1Header, 6, 12, 12); for (int i = 0; i < ipcs.length; i++) { addParagraph(document, writer, xmlWorker, ipcs[i].getWork(), fontWork, 12, 12, 0); addParagraph(document, writer, xmlWorker, ipcs[i].getDescription(), fontNormal, 12, 0, 0); addImage(document, MPSRUI.getFilePath(mpsrID, ipcs[i].getFileName()), "Figure " + ipcs[i].getFigure() + " " + ipcs[i].getTitle(), fontImageCaption, 12, 3, 12); } // -----------------------------------------------------------------------------------------// addOutline(outline1, writer, MPSRUI.TREE_9_2); addSectionTitle(document, MPSRUI.TREE_9_2, fontSection1Header, 6, 12, 12); for (int i = 0; i < opcs.length; i++) { addParagraph(document, writer, xmlWorker, opcs[i].getWork(), fontWork, 12, 12, 0); addParagraph(document, writer, xmlWorker, opcs[i].getDescription(), fontNormal, 12, 0, 0); addImage(document, MPSRUI.getFilePath(mpsrID, opcs[i].getFileName()), "Figure " + opcs[i].getFigure() + " " + opcs[i].getTitle(), fontImageCaption, 12, 3, 12); } // *******************************************************************************************// // Appendix // *******************************************************************************************// if (appendixs.length > 0) { document.add(Chunk.NEXTPAGE); outline1 = addOutline(root, writer, MPSRUI.TREE_APPENDIX); for (int i = 0; i < appendixs.length; i++) { addOutline(outline1, writer, "Appendix " + appendixs[i].getNumber() + " " + appendixs[i].getTitle()); addSectionTitle(document, "Appendix " + appendixs[i].getNumber() + " " + appendixs[i].getTitle(), fontChapterHeader, 0, 12, 12); addParagraph(document, writer, xmlWorker, appendixs[i].getDescription(), fontNormal, 12, 0, 0); importPages(document, writer, mpsrID, appendixs[i].getFileName()); } } // *******************************************************************************************// // Attachment // *******************************************************************************************// if (attachments.length > 0) { document.setPageSize(DEFAULT_PAGE_SIZE); document.add(Chunk.NEXTPAGE); outline1 = addOutline(root, writer, MPSRUI.TREE_ATTACHMENT); for (int i = 0; i < attachments.length; i++) { addOutline(outline1, writer, "Attachment " + attachments[i].getNumber() + " " + attachments[i].getTitle()); addSectionTitle(document, "Attachment " + attachments[i].getNumber() + " " + attachments[i].getTitle(), fontChapterHeader, 0, 12, 12); addParagraph(document, writer, xmlWorker, attachments[i].getDescription(), fontNormal, 12, 0, 0); importPages(document, writer, mpsrID, attachments[i].getFileName()); } } document.close(); // *******************************************************************************************// // retrieve outline PdfReader readerOrig = new PdfReader(baosOrig.toByteArray()); // int origNumberOfPages = readerOrig.getNumberOfPages(); ColumnText ct = new ColumnText(null); ct.addElement(new Paragraph("Table of Contents", fontCoverTitle)); List<HashMap<String, Object>> bookmarkList = SimpleBookmark.getBookmark(readerOrig); fillColumnText(bookmarkList, ct, 18, 0, fontSection2Header); // generate TOC after cover page ByteArrayOutputStream baosTOC = new ByteArrayOutputStream(); PdfStamper stamperTOC = new PdfStamper(readerOrig, baosTOC); int tocPageEnd = 1; while (true) { stamperTOC.insertPage(++tocPageEnd, readerOrig.getPageSize(1)); PdfContentByte underContent = stamperTOC.getUnderContent(tocPageEnd); generatePageHeader(document, underContent, icon, headerTexts); ct.setCanvas(stamperTOC.getOverContent(tocPageEnd)); ct.setSimpleColumn(36, 36, 558, 693); if (!ColumnText.hasMoreText(ct.go())) break; } stamperTOC.close(); // change page labels PdfPageLabels labels = new PdfPageLabels(); labels.addPageLabel(1, PdfPageLabels.LOWERCASE_ROMAN_NUMERALS); labels.addPageLabel(tocPageEnd + 1, PdfPageLabels.DECIMAL_ARABIC_NUMERALS); // add labels ByteArrayOutputStream baosFinal = new ByteArrayOutputStream(); PdfReader readerTOC = new PdfReader(baosTOC.toByteArray()); // String selectPages = String.format("1-%s,%s-%s", tocPageEnd, // tocPageEnd + 1, origNumberOfPages + (tocPageEnd - 1)); // readerTOC.selectPages(selectPages); PdfStamper stamperFinal = new PdfStamper(readerTOC, baosFinal); stamperFinal.getWriter().setPageLabels(labels); stamperFinal.close(); // *******************************************************************************************// // send final PDF to browser response.setHeader("Expires", "0"); response.setHeader("Cache-Control", "must-revalidate, post-check=0, pre-check=0"); response.setHeader("Pragma", "public"); response.setContentType("application/pdf"); response.setContentLength(baosFinal.size()); OutputStream os = response.getOutputStream(); os.write(baosFinal.toByteArray()); os.flush(); os.close(); } catch (DocumentException e) { e.printStackTrace(); } }
From source file:com.poscoict.license.service.CertificateService.java
public Map<String, Object> getLicenseCertification(String userNo, String licenseFileName, HttpServletRequest req) throws Exception { logger.info("_________getLicenseCertification: " + userNo + " " + licenseFileName); String PDFFileName = userNo + licenseFileName; String PDFFilePath = Consts.PDF_PATH + PDFFileName + ".pdf"; String ImgFilePath = Consts.IMG_PATH + PDFFileName + "1." + Consts.IMG_FORMAT; Map<String, Object> map = new HashMap<String, Object>(); map.put("PDFFileName", PDFFileName + ".pdf"); map.put("ImgFileName", PDFFileName + "1." + Consts.IMG_FORMAT); Map<String, Object> licenseInfo = (Map<String, Object>) managementDao.getLicenseCertification(userNo, licenseFileName);/*from w ww . j a va 2 s. c o m*/ Document document = new Document(); try { PdfWriter.getInstance(document, new FileOutputStream(PDFFilePath)); document.open(); Paragraph p0 = new Paragraph(" "); Paragraph p1 = null; p1 = setParagraph("License Certificate", Fonts.FONT20BOLD); p1.setAlignment(Paragraph.ALIGN_CENTER); document.add(p1); document.add(p0); document.add(p0); document.add( setParagraph("? End User (?) : " + licenseInfo.get("USER_NAME"), Fonts.FONT12BOLD)); document.add( setParagraph("? Address (): " + licenseInfo.get("USER_ADDRESS"), Fonts.FONT12BOLD)); document.add( setParagraph("? Project (): " + licenseInfo.get("PROJECT_NAME"), Fonts.FONT12BOLD)); document.add(p0); PdfPTable table = new PdfPTable(2); table.setWidthPercentage(100); PdfPCell cell; cell = new PdfPCell(new Phrase(" Product Description", getFont(Fonts.FONT12BOLD))); cell.setFixedHeight(30); cell.setPaddingTop(8f); table.addCell(cell); cell = new PdfPCell(new Phrase(" " + licenseInfo.get("PRODUCT_FILE_NAME"), getFont(Fonts.FONT12NOAML))); cell.setFixedHeight(30); cell.setPaddingTop(8f); table.addCell(cell); cell = new PdfPCell(new Phrase(" License Number", getFont(Fonts.FONT12BOLD))); cell.setFixedHeight(30); cell.setPaddingTop(8f); table.addCell(cell); cell = new PdfPCell(new Phrase(" " + licenseInfo.get("LICENSE_KEY"), getFont(Fonts.FONT12NOAML))); cell.setFixedHeight(30); cell.setPaddingTop(8f); table.addCell(cell); cell = new PdfPCell(new Phrase(" Quantity", getFont(Fonts.FONT12BOLD))); cell.setFixedHeight(30); cell.setPaddingTop(8f); table.addCell(cell); cell = new PdfPCell( new Phrase(" " + licenseInfo.get("LICENSE_QUANTITY") + " EA", getFont(Fonts.FONT12NOAML))); cell.setFixedHeight(30); cell.setPaddingTop(8f); table.addCell(cell); document.add(table); document.add(p0); List list = new List(false, 20); list.add(new ListItem( " License Certificate ?? ? ? ? ? ?? ??.", getFont(Fonts.FONT12NOAML))); list.add(new ListItem( "License Certificate ? ?? ? ? ? ? ?.", getFont(Fonts.FONT12NOAML))); list.add(new ListItem(", ? ?? .", getFont(Fonts.FONT12NOAML))); document.add(list); document.add(p0); document.add(p0); document.add(p0); document.add(p0); document.add(p0); document.add(p0); document.add(p0); document.add(p0); p1 = setParagraph(licenseInfo.get("USER_START_DATE").toString(), Fonts.FONT20BOLD); p1.setAlignment(Paragraph.ALIGN_CENTER); document.add(p1); p1 = setParagraph(licenseInfo.get("COMPANY_NAME").toString(), Fonts.FONT20BOLD); p1.setAlignment(Paragraph.ALIGN_CENTER); document.add(p1); // Image img = Image.getInstance(Consts.SIGNET_IMG_PATH); // img.setAbsolutePosition(350f, 390f); // document.add(img); document.close(); } catch (DocumentException de) { logger.error(ImgFilePath, de); } catch (IOException ioe) { logger.error(ImgFilePath, ioe); } String temp = req.getSession().getServletContext().getRealPath(Consts.IMG_TEMP_FOLDER); System.out.println("________________________________________________" + temp); if (extractPagesAsImage(PDFFilePath, PDFFileName, 100, "")) { fileCopy(ImgFilePath, temp + File.separator + map.get("ImgFileName")); } return map; }
From source file:com.poscoict.license.service.CertificateService.java
public Map<String, Object> getTechSupportCertificationInfo(String userNo, String productFileId, HttpServletRequest req) throws Exception { logger.info("_________getTechSupportCertificationInfo: " + userNo + " " + productFileId); String PDFFileName = userNo + "_TechSupportCertification"; String PDFFilePath = Consts.PDF_PATH + PDFFileName + ".pdf"; String ImgFilePath = Consts.IMG_PATH + PDFFileName + "1." + Consts.IMG_FORMAT; Map<String, Object> map = new HashMap<String, Object>(); map.put("PDFFileName", PDFFileName + ".pdf"); map.put("ImgFileName", PDFFileName + "1." + Consts.IMG_FORMAT); Map<String, Object> productInfo = managementDao.getTechSupportCertificationInfo(userNo, productFileId); if (productInfo.get("TECH_SUPPORT_DATE").equals("0")) { throw new UserException( "? ? . ?? ?."); }//from w ww.ja v a2 s . co m Document document = new Document(); try { PdfWriter.getInstance(document, new FileOutputStream(PDFFilePath)); document.open(); Paragraph p0 = new Paragraph(" "); Paragraph p1 = null; Paragraph header = new Paragraph("? ", getFont(Fonts.FONT20BOLD)); header.setAlignment(Paragraph.ALIGN_CENTER); document.add(header); document.add(p0); document.add(p0); document.add(p0); p1 = setParagraph("POSCO ICT ? ? " + productInfo.get("PRODUCT_FILE_NAME") + " ? ," + " ? ? ?? ? ? ?" + " ? .", Fonts.FONT18NOAML); document.add(p1); document.add(p0); document.add(p0); p1 = setParagraph("- -", Fonts.FONT18NOAML); p1.setAlignment(Paragraph.ALIGN_CENTER); document.add(p1); document.add(p0); document.add(p0); List list = new List(false, 30); list.add(new ListItem("? ? ? : " + productInfo.get("USER_START_DATE"), getFont(Fonts.FONT18NOAML))); list.add(new ListItem("? : " + productInfo.get("PRODUCT_FILE_NAME") + " (" + productInfo.get("LICENSE_QUANTITY") + "?)", getFont(Fonts.FONT18NOAML))); list.add(new ListItem("? ? : POSCO ICT", getFont(Fonts.FONT18NOAML))); list.add(new ListItem("? : " + productInfo.get("PROJECT_NAME"), getFont(Fonts.FONT18NOAML))); list.add(new ListItem("? : " + productInfo.get("COMPANY_NAME"), getFont(Fonts.FONT18NOAML))); list.add(new ListItem("? ? : " + productInfo.get("TECH_SUPPORT_DATE"), getFont(Fonts.FONT18NOAML))); document.add(list); document.add(p0); document.add(p0); document.add(p0); p1 = setParagraph("POSCO ICT", Fonts.FONT20BOLD); p1.setAlignment(Paragraph.ALIGN_CENTER); document.add(p1); // Image img = Image.getInstance(Consts.SIGNET_IMG_PATH); // img.setAbsolutePosition(350f, 260f); // document.add(img); document.close(); } catch (DocumentException de) { logger.error(ImgFilePath, de); } catch (IOException ioe) { logger.error(ImgFilePath, ioe); } String temp = req.getSession().getServletContext().getRealPath(Consts.IMG_TEMP_FOLDER); if (extractPagesAsImage(PDFFilePath, PDFFileName, 100, "")) { fileCopy(ImgFilePath, temp + File.separator + map.get("ImgFileName")); } return map; }
From source file:com.prjhuellvotweb.controlador.PDF.java
protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { //Preguntar por la sesion del usuario admin HttpSession sessionOk = request.getSession(true); if (sessionOk.getAttribute("admin") != null) { //cambiar a tipo application/pdf response.setContentType("application/pdf;charset=UTF-8"); //flujo de salida OutputStream out = response.getOutputStream(); String texto = request.getParameter("report"); //texto = "Reporte de los proyectos Sena CTGI (Centro tecnologico de gestion industrial) donde se dan a conocer" // + " los nombres de los proyectos y cantidad de votos obtenidos para cada proyecto."; try {/* w ww. j a va 2s .c o m*/ Connection con = Conexion.conectar("mysql"); DAOVoto dao = new DAOVoto(); List<List> lista = dao.estadisticaNumeroVotos(); Voto t = dao.contarVotos(); int to = t.getIdUsuario(); if (!lista.isEmpty() && lista.size() > 0) { try { //programar pdf Document documento = new Document(); //asosciar documento con la salida PdfWriter.getInstance(documento, out);// salida del cocumento en pdf //abrir documento documento.open(); Paragraph par2 = new Paragraph(); Paragraph par4 = new Paragraph(); //agregar una imagen logo sena al pdf Image imagenes = Image .getInstance(getServletContext().getRealPath("") + "/Multimedia/reportes.png"); //Centrar la imagen imagenes.setAlignment(Element.ALIGN_CENTER); //tamao de la imagen imagenes.scaleToFit(530, 520); //agg imagen al documento F:\\Documentos\\yo\\huellvot 2 17-06-2016\\PrjHuellVotWeb\\web\\iCO.png //documento.add(imghuellvot); documento.add(imagenes); //Agg salto de linea par2.add(new Phrase(Chunk.NEWLINE)); par2.add(new Phrase(Chunk.NEWLINE)); //fuente del pdf, tipo de fuente famimilia tamao de letra //Importar ttf que contiene el tipo de letra FontFactory.register( "C:\\Users\\pc\\Desktop\\PrjHuellVotWeb\\web\\fonts\\roboto\\Roboto-Bold.ttf", "Roboto"); //Font fondescripcion = FontFactory.getFont("Roboto"); Font fondescripcion = new Font(Font.getFamily("Roboto"), 16, Font.NORMAL, BaseColor.BLACK); //texto de la descripcion par2.add(new Phrase(texto, fondescripcion)); //justificar descripcion par2.setAlignment(Element.ALIGN_JUSTIFIED); //Agg salto de linea par2.add(new Phrase(Chunk.NEWLINE)); par2.add(new Phrase(Chunk.NEWLINE)); //agregar descripcion al documento documento.add(par2);//agregar todas las propiedades de la descripcin //crear una tabla PdfPTable tabla = new PdfPTable(5);//( Numero de columnas de la tabla) //columnas de la tabla, cabezera y agg un estilo PdfPCell celda = new PdfPCell( new Paragraph("Nmero", FontFactory.getFont("Roboto", 14, Font.BOLD))); PdfPCell celda1 = new PdfPCell( new Paragraph("Nombre", FontFactory.getFont("Roboto", 14, Font.BOLD))); celda1.setColspan(3); PdfPCell celda2 = new PdfPCell( new Paragraph("Votos", FontFactory.getFont("Roboto", 14, Font.BOLD))); //Color de fondo celda.setBackgroundColor(new BaseColor(252, 115, 35)); celda1.setBackgroundColor(new BaseColor(252, 115, 35)); celda2.setBackgroundColor(new BaseColor(252, 115, 35)); //Centrar celda.setHorizontalAlignment(Element.ALIGN_CENTER); celda1.setHorizontalAlignment(Element.ALIGN_CENTER); celda2.setHorizontalAlignment(Element.ALIGN_CENTER); //padding celda.setPadding(8.0f); celda1.setPadding(8.0f); celda2.setPadding(8.0f); //agg columna ala tabla tabla.addCell(celda); tabla.addCell(celda1); tabla.addCell(celda2); for (int i = 0; i < lista.size(); i++) { List l = lista.get(i); //Convertir el entero a string String num = String.valueOf(l.get(0)); String nom = String.valueOf(l.get(1)); String tot = String.valueOf(l.get(2)); //Agregar valores a las celdas PdfPCell c = new PdfPCell( new Paragraph(num, FontFactory.getFont("Roboto", 12, Font.BOLD))); PdfPCell c1 = new PdfPCell( new Paragraph(nom, FontFactory.getFont("Roboto", 12, Font.BOLD))); c1.setColspan(3); PdfPCell c2 = new PdfPCell( new Paragraph(tot, FontFactory.getFont("Roboto", 12, Font.BOLD))); //Padding para las celdas c.setPadding(4.0f); c1.setPadding(4.0f); c2.setPadding(4.0f); //Centrar contenido de celda c.setHorizontalAlignment(Element.ALIGN_CENTER); c2.setHorizontalAlignment(Element.ALIGN_CENTER); //mostrar los resultados de cada columna los agrega a la tabla tabla.addCell(c); tabla.addCell(c1); tabla.addCell(c2); } PdfPCell c1 = new PdfPCell(new Paragraph("Total Votos: ", fondescripcion)); c1.setColspan(4); PdfPCell c2 = new PdfPCell(new Paragraph("" + to, fondescripcion)); c1.setHorizontalAlignment(Element.ALIGN_CENTER); c2.setHorizontalAlignment(Element.ALIGN_CENTER); c1.setPadding(4.0f); c2.setPadding(4.0f); tabla.addCell(c1); tabla.addCell(c2); //Agrega la tabla a el documento documento.add(tabla); //agregar fecha Font fonfecha = new Font(Font.getFamily("Roboto"), 12, Font.NORMAL, BaseColor.LIGHT_GRAY); par4.add(new Phrase("Expedido por HuellVot", fonfecha)); DateFormat formato = DateFormat.getDateInstance(DateFormat.FULL); par4.add(new Paragraph(formato.format(new Date()))); documento.add(par4); //cerrar el documento documento.close(); } catch (DocumentException | IOException e) { e.getMessage(); System.out.println("Error al generar el reporte PDF" + e); } } else { try { Document documento = new Document(); PdfWriter.getInstance(documento, out);// salida del cocumento en pdf //abrir documento documento.open(); System.out.println("no hat datos"); //agregar una imagen logo sena al pdf Image imagenes = Image.getInstance( "C:\\Users\\pc\\Desktop\\PrjHuellVotWeb\\web\\Multimedia\\reportes.png"); //Centrar la imagen imagenes.setAlignment(Element.ALIGN_CENTER); //tamao de la imagen imagenes.scaleToFit(530, 520); //agg imagen al documento F:\\Documentos\\yo\\huellvot 2 17-06-2016\\PrjHuellVotWeb\\web\\iCO.png //documento.add(imghuellvot); documento.add(imagenes); Paragraph par1 = new Paragraph(); Paragraph par2 = new Paragraph(); //Agg salto de linea par1.add(new Phrase(Chunk.NEWLINE)); par1.add(new Phrase(Chunk.NEWLINE)); //fuente del pdf, tipo de fuente famimilia tamao de letra //Importar ttf que contiene el tipo de letra FontFactory.register( "C:\\Users\\pc\\Desktop\\PrjHuellVotWeb\\web\\fonts\\roboto\\Roboto-Bold.ttf", "Roboto"); //Font fondescripcion = FontFactory.getFont("Roboto"); Font fondescripcion = new Font(Font.getFamily("Roboto"), 16, Font.NORMAL, BaseColor.BLACK); //texto de la descripcion par1.add(new Phrase("lo sentimos pero no hay datos para mostrar.!", fondescripcion)); //justificar descripcion par1.setAlignment(Element.ALIGN_CENTER); //Agg salto de linea par1.add(new Phrase(Chunk.NEWLINE)); par1.add(new Phrase(Chunk.NEWLINE)); //agregar descripcion al documento documento.add(par1);//agregar todas las propiedades de la descripcin //agregar fecha Font fonfecha = new Font(Font.getFamily("Roboto"), 12, Font.NORMAL, BaseColor.LIGHT_GRAY); par2.add(new Phrase("Expedido por HuellVot", fonfecha)); DateFormat formato = DateFormat.getDateInstance(DateFormat.FULL); par2.add(new Paragraph(formato.format(new Date()))); documento.add(par2); //cerrar el documento documento.close(); } catch (DocumentException ex) { ex.getMessage(); System.out.println("Error al generar el reporte PDF sin datos registrados" + ex); } } } finally { out.close(); } } else { sessionOk.invalidate(); response.sendRedirect("index.jsp"); } }
From source file:com.quix.aia.cn.imo.mapper.ApplicationFormPDFMaintenance.java
License:Open Source License
private static Document ESingnature(Document document, PdfWriter writer, AddressBook addressbook) { // TODO Auto-generated method stub log.log(Level.INFO, "ApplicationFormPDFMaintenance --> ESingnature "); try {// w w w .j av a2s. c o m document.newPage(); PdfPTable table = new PdfPTable(2); table.setSpacingBefore(10); table.setWidthPercentage(100f); PdfPCell c1 = new PdfPCell(new Phrase("E-singnature ")); c1.setHorizontalAlignment(Element.ALIGN_LEFT); c1.setColspan(4); c1.setBorder(Rectangle.LEFT | Rectangle.RIGHT | Rectangle.TOP); c1.setFixedHeight(30f); c1.setBackgroundColor(BaseColor.LIGHT_GRAY); c1.setBorder(Rectangle.BOX); c1.setFixedHeight(25f); table.addCell(c1); table.setHeaderRows(1); for (int i = 0; i < 2; i++) { c1 = new PdfPCell(new Phrase(" ", font)); c1.setBorder(Rectangle.NO_BORDER); c1.setLeading(4f, 0f); c1.setFixedHeight(15f); table.addCell(c1); } Iterator itr = null; CandidateESignature esignature = new CandidateESignature(); if (addressbook.getCandidateESignatures().size() > 0) { itr = addressbook.getCandidateESignatures().iterator(); esignature = (CandidateESignature) itr.next(); } c1 = new PdfPCell(new Phrase("Branch : " + esignature.getBranch(), font)); c1.setBorder(Rectangle.NO_BORDER); c1.setLeading(4f, 0f); c1.setFixedHeight(15f); c1.setBorder(Rectangle.BOTTOM); table.addCell(c1); c1 = new PdfPCell(new Phrase("Servicing Department : " + esignature.getServiceDepartment(), font)); c1.setBorder(Rectangle.NO_BORDER); c1.setLeading(4f, 0f); c1.setFixedHeight(15f); c1.setBorder(Rectangle.BOTTOM); table.addCell(c1); for (int i = 0; i < 2; i++) { c1 = new PdfPCell(new Phrase(" ", font)); c1.setBorder(Rectangle.NO_BORDER); c1.setLeading(4f, 0f); c1.setFixedHeight(15f); table.addCell(c1); } c1 = new PdfPCell(new Phrase("City : " + esignature.getCity(), font)); c1.setBorder(Rectangle.NO_BORDER); c1.setLeading(4f, 0f); c1.setFixedHeight(15f); c1.setBorder(Rectangle.BOTTOM); table.addCell(c1); c1 = new PdfPCell(new Phrase("Agent Code : " + esignature.getAgentId(), font)); c1.setBorder(Rectangle.NO_BORDER); c1.setLeading(4f, 0f); c1.setFixedHeight(15f); c1.setBorder(Rectangle.BOTTOM); table.addCell(c1); for (int i = 0; i < 4; i++) { c1 = new PdfPCell(new Phrase(" ", font)); c1.setBorder(Rectangle.NO_BORDER); c1.setLeading(4f, 0f); c1.setFixedHeight(15f); table.addCell(c1); } document.add(table); table = new PdfPTable(2); table.setSpacingBefore(10); table.setWidthPercentage(100f); table.setWidths(new int[] { 80, 20 }); c1 = new PdfPCell(new Phrase("Presently attached with another insurance Company ? ", font)); c1.setBorder(Rectangle.NO_BORDER); c1.setLeading(4f, 0f); c1.setFixedHeight(15f); table.addCell(c1); c1 = new PdfPCell(new Phrase("Yes \t\t\t\t\t\t\t\t No", font)); c1.setBorder(Rectangle.NO_BORDER); c1.setLeading(4f, 0f); c1.setFixedHeight(15f); table.addCell(c1); for (int i = 0; i < 2; i++) { c1 = new PdfPCell(new Phrase(" ", font)); c1.setBorder(Rectangle.NO_BORDER); c1.setLeading(4f, 0f); c1.setFixedHeight(15f); table.addCell(c1); } c1 = new PdfPCell( new Phrase("Presently in contact with any other AIA'S servicing Department ? ", font)); c1.setBorder(Rectangle.NO_BORDER); c1.setLeading(4f, 0f); c1.setFixedHeight(15f); table.addCell(c1); c1 = new PdfPCell(new Phrase("Yes \t\t\t\t\t\t\t\t No", font)); c1.setBorder(Rectangle.NO_BORDER); c1.setLeading(4f, 0f); c1.setFixedHeight(15f); table.addCell(c1); for (int i = 0; i < 2; i++) { c1 = new PdfPCell(new Phrase(" ", font)); c1.setBorder(Rectangle.NO_BORDER); c1.setLeading(4f, 0f); c1.setFixedHeight(15f); table.addCell(c1); } c1 = new PdfPCell( new Phrase("Taken LOMBRA occupational test or PSP test in the past ? If Yes, ", font)); c1.setBorder(Rectangle.NO_BORDER); c1.setLeading(4f, 0f); c1.setFixedHeight(15f); table.addCell(c1); c1 = new PdfPCell(new Phrase("Yes \t\t\t\t\t\t\t\t No", font)); c1.setBorder(Rectangle.NO_BORDER); c1.setLeading(4f, 0f); c1.setFixedHeight(15f); table.addCell(c1); for (int i = 0; i < 2; i++) { c1 = new PdfPCell(new Phrase(" ", font)); c1.setBorder(Rectangle.NO_BORDER); c1.setLeading(4f, 0f); c1.setFixedHeight(15f); table.addCell(c1); } c1 = new PdfPCell(new Phrase("Please provide the result. ", font)); c1.setBorder(Rectangle.NO_BORDER); c1.setLeading(4f, 0f); c1.setFixedHeight(15f); table.addCell(c1); for (int i = 0; i < 5; i++) { c1 = new PdfPCell(new Phrase(" ", font)); c1.setBorder(Rectangle.NO_BORDER); c1.setLeading(4f, 0f); c1.setFixedHeight(15f); table.addCell(c1); } document.add(table); Paragraph para1 = new Paragraph(); para1.add(new Chunk("Applicant's Declaration ", font)); para1.setAlignment(Element.ALIGN_LEFT); para1.setSpacingAfter(5f); document.add(para1); table = new PdfPTable(2); table.setSpacingBefore(10); table.setWidthPercentage(100f); for (int i = 0; i < 4; i++) { c1 = new PdfPCell(new Phrase(" ", font)); c1.setBorder(Rectangle.NO_BORDER); c1.setLeading(4f, 0f); c1.setFixedHeight(15f); table.addCell(c1); c1 = new PdfPCell(new Phrase(" ", font)); c1.setBorder(Rectangle.NO_BORDER); c1.setLeading(4f, 0f); c1.setFixedHeight(15f); table.addCell(c1); } c1 = new PdfPCell(new Phrase("Application Date", font)); c1.setBorder(Rectangle.NO_BORDER); c1.setLeading(4f, 0f); c1.setFixedHeight(15f); table.addCell(c1); c1 = new PdfPCell(new Phrase("Applicant/Candidate Name :", font)); c1.setBorder(Rectangle.NO_BORDER); c1.setLeading(4f, 0f); c1.setFixedHeight(15f); table.addCell(c1); if (esignature.getApplicationDate() != null) { c1 = new PdfPCell(new Phrase(format.format(esignature.getApplicationDate()), font)); c1.setBorder(Rectangle.NO_BORDER); c1.setLeading(4f, 0f); c1.setFixedHeight(15f); table.addCell(c1); } else { c1 = new PdfPCell(new Phrase("", font)); c1.setBorder(Rectangle.NO_BORDER); c1.setLeading(4f, 0f); c1.setFixedHeight(15f); table.addCell(c1); } c1 = new PdfPCell(new Phrase(esignature.getCandidateName(), font)); c1.setBorder(Rectangle.NO_BORDER); c1.setLeading(4f, 0f); c1.setFixedHeight(15f); table.addCell(c1); for (int i = 0; i < 4; i++) { c1 = new PdfPCell(new Phrase(" ", font)); c1.setBorder(Rectangle.NO_BORDER); c1.setLeading(4f, 0f); c1.setFixedHeight(15f); table.addCell(c1); c1 = new PdfPCell(new Phrase(" ", font)); c1.setBorder(Rectangle.NO_BORDER); c1.setLeading(4f, 0f); c1.setFixedHeight(15f); table.addCell(c1); } document.add(table); para1 = new Paragraph(); para1.add(new Chunk("E-Signature : ", font)); para1.setAlignment(Element.ALIGN_LEFT); para1.setSpacingAfter(5f); document.add(para1); c1 = new PdfPCell(new Phrase(" ", font)); c1.setBorder(Rectangle.NO_BORDER); c1.setLeading(4f, 0f); c1.setFixedHeight(15f); table.addCell(c1); if (esignature.geteSignaturePhoto() != null) { Image image = Image.getInstance(esignature.geteSignaturePhoto()); para1 = new Paragraph(); para1.add(image); para1.setAlignment(Element.ALIGN_LEFT); para1.setSpacingAfter(5f); document.add(para1); } else { para1 = new Paragraph(); para1.add(""); para1.setAlignment(Element.ALIGN_LEFT); para1.setSpacingAfter(5f); document.add(para1); } } catch (Exception e) { // TODO Auto-generated catch block log.log(Level.INFO, "ApplicationFormPDFMaintenance --> ESingnature " + e.getMessage()); e.printStackTrace(); e.printStackTrace(); LogsMaintenance logsMain = new LogsMaintenance(); StringWriter errors = new StringWriter(); e.printStackTrace(new PrintWriter(errors)); logsMain.insertLogs("ApplicationFormPDFMaintenance", Level.SEVERE + "", errors.toString()); } return document; }
From source file:com.sapito.pdf.PDFView.PDFGeneratorActivosFijos.java
public void crearPDFInversion(HttpServletResponse hsr1, ArrayList<HashMap> resultados, double granTotalDepActual, double granTotalValorActual, double granTotalValorOr) throws Exception { Document dcmntaf = new Document(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); PdfWriter.getInstance(dcmntaf, baos); System.out.println(resultados.get(0).size()); dcmntaf.open();/*from w ww . j av a2s . c om*/ dcmntaf.open(); dcmntaf.addTitle("Sapito PDFs"); dcmntaf.addSubject("Pdf de sapito"); //------------------------ TAIS ______________________________ Image tais = Image.getInstance(new URL("http://localhost:8080/SAPITO/resources/img/tais-banner.jpg")); dcmntaf.add(tais); //--------------------- BODY --------------------------------------------------------- Image body = Image.getInstance(new URL("http://localhost:8080/SAPITO/resources/img/body.png")); body.setAlignment(Image.UNDERLYING); body.setTransparency(new int[] { 0x00, 0x10 }); body.setAbsolutePosition(50, 250); dcmntaf.add(body); //------------------------------------------------------------------------------------------- Image footer = Image.getInstance(new URL("http://localhost:8080/SAPITO/resources/img/footer.jpg")); footer.setAbsolutePosition(50, 20); dcmntaf.add(footer); //---------------------- TITLE --------------------------- String titulo = "Reporte de Inversin"; //Cambiar el titulo del PDF aqui Font f = new Font(FontFamily.HELVETICA, 25.0f, Font.BOLD, BaseColor.BLACK); Chunk c = new Chunk(titulo + " \n ", f); c.setBackground(BaseColor.WHITE); Paragraph title = new Paragraph(c); title.setAlignment(Element.ALIGN_CENTER); String titulo2 = "Reporte de Activos Fijos por Tipo"; //Cambiar el titulo del PDF aqui Font f2 = new Font(FontFamily.HELVETICA, 12.0f, Font.NORMAL, BaseColor.BLACK); Chunk c2 = new Chunk(titulo2 + " \n ", f2); c2.setBackground(BaseColor.WHITE); Paragraph title2 = new Paragraph(c2); title2.setAlignment(Element.ALIGN_LEFT); title2.setIndentationLeft(50); //------------------------- CONTENIDO ------------------------------------------------------- dcmntaf.add(title); //Titulo del PDF dcmntaf.add(title2); PdfPTable table = new PdfPTable(4); // PdfPCell cell; // cell = new PdfPCell(new Phrase("Tipo de A", FontFactory.getFont("TIMES_ROMAN", 12, Font.BOLD, BaseColor.BLACK))); // table.addCell(cell); table.addCell("Tipo de Activo fijo"); table.addCell("Valor Original"); table.addCell("Depreciacin Actual "); table.addCell("Valor Actual"); // Iterator it = resultados.get(0).entrySet().iterator(); for (int i = 0; i < resultados.size(); i++) { table.addCell(resultados.get(i).get("tipo").toString()); table.addCell(resultados.get(i).get("valorOriginal").toString()); table.addCell(resultados.get(i).get("depreciacionActual").toString()); table.addCell(resultados.get(i).get("valoreActual").toString()); } // while (it.hasNext()) { // Map.Entry e = (Map.Entry) it.next(); // System.out.println(e.getKey() + " " + e.getValue()); // // table.addCell(e.getValue().toString()); // } dcmntaf.add(table); String titulo3 = "Reporte Total de Activos Fijos"; //Cambiar el titulo del PDF aqui Font f3 = new Font(FontFamily.HELVETICA, 12.0f, Font.NORMAL, BaseColor.BLACK); Chunk c3 = new Chunk(titulo3 + " \n ", f3); c3.setBackground(BaseColor.WHITE); Paragraph title3 = new Paragraph(c3); title3.setAlignment(Element.ALIGN_LEFT); title3.setIndentationLeft(50); dcmntaf.add(title3); PdfPTable table2 = new PdfPTable(3); // PdfPCell cell; // cell = new PdfPCell(new Phrase("Tipo de A", FontFactory.getFont("TIMES_ROMAN", 12, Font.BOLD, BaseColor.BLACK))); // table.addCell(cell); table2.addCell("Valor Original Total"); table2.addCell("Depreciacin Anual Total"); table2.addCell("Valor Total"); table2.addCell(granTotalValorOr + ""); table2.addCell(granTotalDepActual + ""); table2.addCell(granTotalValorActual + ""); dcmntaf.add(table2); PdfPTable table3 = new PdfPTable(1); table3.setWidthPercentage(100.0f); table3.setWidths(new float[] { 2.0f }); table3.setSpacingBefore(10); // define font for table header row Font font = FontFactory.getFont(FontFactory.COURIER_BOLD); font.setColor(BaseColor.WHITE); // define table header cell PdfPCell cell = new PdfPCell(); cell.setBackgroundColor(BaseColor.BLUE); cell.setPadding(5); // write table header cell.setPhrase(new Phrase("Resultado", font)); table3.addCell(cell); Depreciacion dep = new Depreciacion(); String bla = a + " "; table3.addCell(bla); //-------------------------- FIN CONTENIDO ----------------- dcmntaf.close(); dcmntaf.close(); byte[] bytes = baos.toByteArray(); hsr1.setContentType("application/pdf"); hsr1.setContentLength(bytes.length); hsr1.getOutputStream().write(bytes); }
From source file:com.sapito.pdf.PDFView.PDFGeneratorContabilidad.java
public void crearEstadoResultados(HttpServletResponse hsr1, String ingresos, String cVenta, String cGeneral, String cImpu, String cImpTot) throws Exception { Document document = new Document(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); PdfWriter.getInstance(document, baos); document.open();/* w w w. ja va 2 s . c o m*/ document.addTitle("Sapito PDFs"); document.addSubject("Pdf de sapito"); //------------------------ TAIS ______________________________ Image tais = Image.getInstance(new URL("http://localhost:8080/SAPITO/resources/img/tais-banner.jpg")); document.add(tais); //--------------------- BODY --------------------------------------------------------- Image body = Image.getInstance(new URL("http://localhost:8080/SAPITO/resources/img/body.png")); body.setAlignment(Image.UNDERLYING); body.setTransparency(new int[] { 0x00, 0x10 }); body.setAbsolutePosition(50, 250); document.add(body); //------------------------------------------------------------------------------------------- Image footer = Image.getInstance(new URL("http://localhost:8080/SAPITO/resources/img/footer.jpg")); footer.setAbsolutePosition(50, 20); document.add(footer); //---------------------- TITLE --------------------------- String titulo = "Estado de Resultados"; //Cambiar el titulo del PDF aqui Font f = new Font(FontFamily.HELVETICA, 25.0f, Font.BOLD, BaseColor.BLACK); Chunk c = new Chunk(titulo + " \n ", f); c.setBackground(BaseColor.WHITE); Paragraph title = new Paragraph(c); title.setAlignment(Element.ALIGN_CENTER); //------------------------- CONTENIDO ------------------------------------------------------- document.add(title); //Titulo del PDF PdfPTable table = new PdfPTable(2); table.addCell("Ingresos"); table.addCell(ingresos);//valor table.addCell("Costo de Venta"); table.addCell(cVenta);//valor table.addCell("Costos Generales"); table.addCell(cGeneral);//valor table.addCell("Impuestos de Ingresos"); table.addCell(cImpu);//valor table.addCell("Impuesto de Costos Totales"); table.addCell(cImpTot);//valor document.add(table); document.close(); byte[] bytes = baos.toByteArray(); hsr1.setContentType("application/pdf"); hsr1.setContentLength(bytes.length); hsr1.getOutputStream().write(bytes); }
From source file:com.sapito.pdf.PDFView.PDFGeneratorContabilidad.java
public void crearVariacionContable(HttpServletResponse hsr1, String sInicial, String aumento, String utilidad, String disminucion, String perdidas, String sFinal) throws Exception { Document document = new Document(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); PdfWriter.getInstance(document, baos); document.open();/*from www .j av a2 s.c om*/ document.addTitle("Sapito PDFs"); document.addSubject("Pdf de sapito"); //------------------------ TAIS ______________________________ Image tais = Image.getInstance(new URL("http://localhost:8080/SAPITO/resources/img/tais-banner.jpg")); document.add(tais); //--------------------- BODY --------------------------------------------------------- Image body = Image.getInstance(new URL("http://localhost:8080/SAPITO/resources/img/body.png")); body.setAlignment(Image.UNDERLYING); body.setTransparency(new int[] { 0x00, 0x10 }); body.setAbsolutePosition(50, 250); document.add(body); //------------------------------------------------------------------------------------------- Image footer = Image.getInstance(new URL("http://localhost:8080/SAPITO/resources/img/footer.jpg")); footer.setAbsolutePosition(50, 20); document.add(footer); //---------------------- TITLE --------------------------- String titulo = "Variaciones de Capital Contable"; //Cambiar el titulo del PDF aqui Font f = new Font(FontFamily.HELVETICA, 25.0f, Font.BOLD, BaseColor.BLACK); Chunk c = new Chunk(titulo + " \n ", f); c.setBackground(BaseColor.WHITE); Paragraph title = new Paragraph(c); title.setAlignment(Element.ALIGN_CENTER); //------------------------- CONTENIDO ------------------------------------------------------- document.add(title); //Titulo del PDF PdfPTable table = new PdfPTable(2); table.addCell("Saldo al inicio del ejercicio"); table.addCell(sInicial);//valor table.addCell("Aumentos"); table.addCell(aumento);//valor table.addCell("Utilidades"); table.addCell(utilidad);//valor table.addCell("Disminuciones"); table.addCell(disminucion);//valor table.addCell("Perdidas"); table.addCell(perdidas);//valor table.addCell("Saldo al final del ejercicio"); table.addCell(sFinal);//valor document.add(table); document.close(); byte[] bytes = baos.toByteArray(); hsr1.setContentType("application/pdf"); hsr1.setContentLength(bytes.length); hsr1.getOutputStream().write(bytes); }
From source file:com.sapito.pdf.PDFView.PDFGeneratorContabilidad.java
public void crearFlujo(HttpServletResponse hsr1, String operacion, String sInicio, String sFin) throws Exception { Document document = new Document(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); PdfWriter.getInstance(document, baos); document.open();/*from w ww . j a va 2 s.com*/ document.addTitle("Sapito PDFs"); document.addSubject("Pdf de sapito"); //------------------------ TAIS ______________________________ Image tais = Image.getInstance(new URL("http://localhost:8080/SAPITO/resources/img/tais-banner.jpg")); document.add(tais); //--------------------- BODY --------------------------------------------------------- Image body = Image.getInstance(new URL("http://localhost:8080/SAPITO/resources/img/body.png")); body.setAlignment(Image.UNDERLYING); body.setTransparency(new int[] { 0x00, 0x10 }); body.setAbsolutePosition(50, 250); document.add(body); //------------------------------------------------------------------------------------------- Image footer = Image.getInstance(new URL("http://localhost:8080/SAPITO/resources/img/footer.jpg")); footer.setAbsolutePosition(50, 20); document.add(footer); //---------------------- TITLE --------------------------- String titulo = "Flujo de Efectivo"; //Cambiar el titulo del PDF aqui Font f = new Font(FontFamily.HELVETICA, 25.0f, Font.BOLD, BaseColor.BLACK); Chunk c = new Chunk(titulo + " \n ", f); c.setBackground(BaseColor.WHITE); Paragraph title = new Paragraph(c); title.setAlignment(Element.ALIGN_CENTER); //------------------------- CONTENIDO ------------------------------------------------------- document.add(title); //Titulo del PDF PdfPTable table = new PdfPTable(2); table.addCell("Operacin"); table.addCell(operacion);//valor table.addCell("Saldo al inicio del ao"); table.addCell(sInicio);//valor table.addCell("Saldo al inicio del ao"); table.addCell(sFin);//valor document.add(table); document.close(); byte[] bytes = baos.toByteArray(); hsr1.setContentType("application/pdf"); hsr1.setContentLength(bytes.length); hsr1.getOutputStream().write(bytes); }
From source file:com.sapito.pdf.PDFView.PDFGeneratorContabilidad.java
public void crearBalance(HttpServletResponse hsr1, String aCirculante, String aNCirculante, String tActivos, String pasivo) throws Exception { Document document = new Document(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); PdfWriter.getInstance(document, baos); document.open();// w w w.ja v a 2s. c o m document.addTitle("Sapito PDFs"); document.addSubject("Pdf de sapito"); //------------------------ TAIS ______________________________ Image tais = Image.getInstance(new URL("http://localhost:8080/SAPITO/resources/img/tais-banner.jpg")); document.add(tais); //--------------------- BODY --------------------------------------------------------- Image body = Image.getInstance(new URL("http://localhost:8080/SAPITO/resources/img/body.png")); body.setAlignment(Image.UNDERLYING); body.setTransparency(new int[] { 0x00, 0x10 }); body.setAbsolutePosition(50, 250); document.add(body); //------------------------------------------------------------------------------------------- Image footer = Image.getInstance(new URL("http://localhost:8080/SAPITO/resources/img/footer.jpg")); footer.setAbsolutePosition(50, 20); document.add(footer); //---------------------- TITLE --------------------------- String titulo = "Balance General"; //Cambiar el titulo del PDF aqui Font f = new Font(FontFamily.HELVETICA, 25.0f, Font.BOLD, BaseColor.BLACK); Chunk c = new Chunk(titulo + " \n ", f); c.setBackground(BaseColor.WHITE); Paragraph title = new Paragraph(c); title.setAlignment(Element.ALIGN_CENTER); //------------------------- CONTENIDO ------------------------------------------------------- document.add(title); //Titulo del PDF PdfPTable table = new PdfPTable(2); table.addCell("Activo circulante"); table.addCell(aCirculante);//valor table.addCell("Activo no circulante"); table.addCell(aNCirculante);//valor table.addCell("total activos"); table.addCell(tActivos);//valor table.addCell("pasivo"); table.addCell(pasivo);//valor document.add(table); document.close(); byte[] bytes = baos.toByteArray(); hsr1.setContentType("application/pdf"); hsr1.setContentLength(bytes.length); hsr1.getOutputStream().write(bytes); }