List of usage examples for com.itextpdf.text Paragraph setIndentationLeft
public void setIndentationLeft(float indentation)
From source file:com.kohmiho.mpsr.export.PDFGenerator.java
private void addImage(Document document, String filename, String caption, Font font, int indentationLeft, int spacingBefore, int spacingAfter) throws BadElementException, MalformedURLException, IOException, DocumentException { if (null == filename) { addParagraph(document, null, null, String.format("[*** No Picture for %s ***]", caption), font, indentationLeft, 0, 0);/*from ww w.j a va2 s . co m*/ return; } try { Paragraph paragraph = new Paragraph(); paragraph.setIndentationLeft(indentationLeft); paragraph.setSpacingBefore(spacingBefore); paragraph.setSpacingAfter(spacingAfter); if (null != font) paragraph.setFont(font); paragraph.setKeepTogether(true); paragraph.setAlignment(Element.ALIGN_CENTER); Image image = Image.getInstance(filename); image.scaleToFit(400, 400); paragraph.add(new Chunk(image, 0, 0, true)); paragraph.add(new Chunk("\n")); paragraph.add(caption); document.add(paragraph); } catch (Exception e) { addParagraph(document, null, null, String.format("[*** Unable to render picture for %s ***]", caption), font, indentationLeft, 0, 0); } }
From source file:com.mycompany.peram_inclassexam.WritePDFFile.java
public void createPDF(AccountDetails account) throws DocumentException, FileNotFoundException, BadElementException, IOException { Document document = new Document(PageSize.A4, 50, 50, 50, 50); PdfWriter write = PdfWriter.getInstance(document, new FileOutputStream(account.getLastName() + "_output.pdf")); document.open();//from w w w. ja va2 s . c o m Image image = Image.getInstance("image.png"); image.scaleToFit(450f, 1800f); document.add(image); document.add(new Paragraph( "--------------------------------------------------------------------------------------------------------------------------")); Paragraph welcomeParagraph = new Paragraph( "Welcome! " + account.getFirstName() + " " + account.getLastName() + "!"); welcomeParagraph.setSpacingBefore(50); document.add(welcomeParagraph); String firstName = "First Name: " + account.getFirstName(); String lastName = "Last Name: " + account.getLastName(); String acctNumber = "Account Number: " + account.getAccountNo(); String acctBalance = String.format("Account Balance: $%.1f", account.getAccountBalance()); Paragraph detailsPara = new Paragraph("Below are your Account Details:\n" + firstName + "\n" + lastName + "\n" + acctNumber + "\n" + acctBalance); detailsPara.setIndentationLeft(30); detailsPara.setSpacingBefore(20); document.add(detailsPara); document.close(); write.close(); }
From source file:com.norbsoft.pdfconverter.helpers.PDFHelper.java
License:Open Source License
public int generate(String saveUrl, SerializableBitmap sign, Form form, ArrayList<String> photos, ArrayList<String> workers) { try {/*from w ww .j a va2 s.co m*/ Document document = new Document(); url = saveUrl; PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(url)); document.setMargins(20, 20, 20, 20); document.open(); Bitmap inputLogo = BitmapFactory.decodeStream(context.getAssets().open("logo.jpg")); ByteArrayOutputStream outstream = new ByteArrayOutputStream(); inputLogo.compress(Bitmap.CompressFormat.JPEG, 100, outstream); Image logo = Image.getInstance(outstream.toByteArray()); Bitmap inputQR = BitmapFactory.decodeStream(context.getAssets().open("qr.jpg")); outstream = new ByteArrayOutputStream(); inputQR.compress(Bitmap.CompressFormat.JPEG, 100, outstream); Image qr = Image.getInstance(outstream.toByteArray()); outstream = new ByteArrayOutputStream(); sign.getImage().compress(Bitmap.CompressFormat.JPEG, 100, outstream); Image sgn = Image.getInstance(outstream.toByteArray()); qr.scaleAbsolute(90f, 90f); qr.setAbsolutePosition(340f, 705f); logo.scaleAbsolute(150f, 50f); logo.setAbsolutePosition(50f, 750f); sgn.scaleAbsolute(130f, 30f); sgn.setAbsolutePosition(25f, 75f); Paragraph p = new Paragraph("\r\n\r\n\r\nMPWiK S.A.\r\n50-421 Wrocaw\r\nul.Na Grobli 14-16", normal); p.setIndentationLeft(420f); document.add(p); p = new Paragraph("RAPORT WYMIANY WODOMIERZA", bold); p.setAlignment(Element.ALIGN_CENTER); p.setSpacingBefore(60f); document.add(p); document.add(table(form)); p = new Paragraph(form.getInformations(), normal); p.setAlignment(Element.ALIGN_LEFT); p.setIndentationLeft(50f); p.setSpacingBefore(20f); document.add(p); document.add(signTable(form, sgn, workers)); document.add(logo); document.add(qr); if (photos != null && photos.size() > 0) { document.newPage(); for (int i = 0; i < photos.size(); i++) { try { if (photos.get(i) != null && !photos.get(i).equals("")) { Log.d(TAG, photos.get(i)); Bitmap temp = PictureHelper.bitmapFromUrl(photos.get(i)); outstream = new ByteArrayOutputStream(); temp.compress(Bitmap.CompressFormat.JPEG, 100, outstream); Image photo = Image.getInstance(outstream.toByteArray()); photo.scaleToFit(document.getPageSize().getWidth() - 50, document.getPageSize().getHeight()); document.add(photo); } } catch (Exception e) { } } } document.close(); writer.close(); return 1; } catch (FileNotFoundException e) { Log.e(TAG, e.getMessage()); return 0; } catch (DocumentException e) { Log.e(TAG, e.getMessage()); return 0; } catch (IOException e) { Log.e(TAG, e.getMessage()); return 0; } catch (Exception e) { Log.e(TAG, e.getMessage()); return 0; } }
From source file:com.pdi.util.PdfGenerator.java
public static void generarPresupuesto(String lugar, Date fecha, float cantidad, String tipo, Cliente cliente, float precio, Aliado aliado, String path) { try {//from w ww .j ava 2 s . com NEGRITA_12_VERDE.setColor(145, 189, 57); long miliSemana = System.currentTimeMillis() + (86400 * 7 * 1000); Date vtoPresup = new Date(miliSemana); float precioPers = precio / cantidad; int precioTotalInt = Math.round(precio); int precioPersInt = Math.round(precioPers); int cantPersonasInt = Math.round(cantidad); //Referencia al objeto Doc Document document = new Document(PageSize.A4, //Dimensiones 36, //margIzq 36, //margDer 36, //margenSup 36); // margenInf //Creamos el archivo fisico FileOutputStream salida = new FileOutputStream(path); //Referencia e inicializacion del objeto que "escribe" el PDF PdfWriter writer = PdfWriter.getInstance(document, salida); writer.setInitialLeading(0); //Imagen Logo Image logoPDI = Image.getInstance("Logo PDI.png"); logoPDI.scaleToFit(215, 205); logoPDI.setAlignment(Chunk.ALIGN_LEFT); //image.setAbsolutePosition(200, 200); //Imagen QR Image qr = Image.getInstance("QR PDI.png"); qr.scaleToFit(211, 165); qr.setAbsolutePosition(295, PageSize.A4.getHeight() - 390); //Parrafo info evento Paragraph infoEvento = new Paragraph(); infoEvento.add(new Chunk("Informacin del Evento", NEGRITA_SUB_12)); infoEvento.add(Chunk.NEWLINE); infoEvento.add(negritaNormal("Solicitante: ", cliente.toString())); infoEvento.add(negritaNormal("Evento: ", tipo)); infoEvento.add(negritaNormal("Cantidad de personas: ", Integer.toString(cantPersonasInt))); infoEvento.add(negritaNormal("Fecha: ", General.formatoFecha.format(fecha))); infoEvento.add(negritaNormal("Lugar: ", lugar)); infoEvento.add(Chunk.NEWLINE); infoEvento.setAlignment(Paragraph.ALIGN_LEFT); //Parrafo Modalidad del Servicio Paragraph modalidadServicio = new Paragraph(); modalidadServicio.add(new Chunk("Modalidad Servicio Integral", NEGRITA_SUB_12)); modalidadServicio.add(Chunk.NEWLINE); modalidadServicio.add(new Chunk("Nuestro servicio incluye la totalidad de lo referido a" + " los elementos necesarios para el despacho de bebidas: Barras, Bartenders," + " Artculos de Coctelera, Insumos de calidad para los tragos y Mucha Buena Onda." + " Con esta modalidad aseguramos la expedicin de " + "los tragos desde las 00hs hasta las 05hs, para que se desentiendan del asunto " + "y disfruten al mximo.", NORMAL_12)); modalidadServicio.setAlignment(Paragraph.ALIGN_LEFT); //Parrafo Ver Carta Paragraph verCarta = new Paragraph(); verCarta.add(negritaNormal("\u2022 Carta de Tragos: ", "Ver archivo adjunto.")); verCarta.setIndentationLeft(20); verCarta.add(Chunk.NEWLINE); verCarta.setAlignment(Paragraph.ALIGN_LEFT); //Parrafo Titulo Info Contratacion Paragraph infoContratacionTitulo = new Paragraph(); infoContratacionTitulo.add(new Chunk("Informacin de Contratacin", NEGRITA_SUB_12)); infoContratacionTitulo.setAlignment(Paragraph.ALIGN_LEFT); //Parrafo Inf de Contratacion Paragraph infoContratacion = new Paragraph(); infoContratacion.add(negritaNormal("\u2022 Mtodo de contratacin y reserva de la fecha: ", "A travs de contrato firmado por ambas partes. ")); Phrase lineaCosto = new Phrase(); lineaCosto.add(new Chunk("\u2022 Costo: ", NEGRITA_12)); lineaCosto.add(new Chunk("$" + Integer.toString(precioPersInt) + " ", NEGRITA_14)); lineaCosto.add(new Chunk("por persona ", NEGRITA_12)); lineaCosto.add(new Chunk("(Total: $" + Integer.toString(precioTotalInt) + ")", NEGRITA_14)); infoContratacion.add(lineaCosto); infoContratacion.add(Chunk.NEWLINE); infoContratacion.add(negritaNormal("\u2022 Forma de Pago : ", "50% al momento de la firma del contrato y 50% como mximo una semana antes del evento. ")); infoContratacion.add(Chunk.NEWLINE); infoContratacion.setIndentationLeft(20); infoContratacion.setFirstLineIndent(0); infoContratacion.setAlignment(Paragraph.ALIGN_LEFT); //Parrafo Despedida Paragraph despedida = new Paragraph(); despedida.add(new Phrase("Quedamos al aguardo de tus comentarios,", NEGRITA_14)); despedida.add(Chunk.NEWLINE); despedida.add(new Phrase("Muchas Gracias.", NEGRITA_14)); despedida.add(Chunk.NEWLINE); despedida.add(Chunk.NEWLINE); despedida.setAlignment(Paragraph.ALIGN_LEFT); //Parrafo Firma Paragraph firma = new Paragraph(); firma.add(new Phrase("Piel de Iguana Tragos.-", NEGRITA_CUR_14)); firma.add(Chunk.NEWLINE); firma.add(new Phrase("Cel.: 3462-15337860", NEGRITA_12_VERDE)); firma.setAlignment(Paragraph.ALIGN_RIGHT); float llxLink = 279; float llyLink = PageSize.A4.getHeight() - 145; float anchoLink = 199; float altoLink = 16; //Link al facebook URL urlPDI = new URL("https://www.facebook.com/pieldeiguanatragos.vt"); PdfAction irAlFace = new PdfAction(urlPDI); Rectangle linkLocation = new Rectangle(llxLink, llyLink, llxLink + anchoLink, llyLink + altoLink); PdfAnnotation link = PdfAnnotation.createLink(writer, linkLocation, PdfAnnotation.HIGHLIGHT_NONE, irAlFace); link.setBorder(new PdfBorderArray(0, 0, 0)); writer.addAnnotation(link); //Espacios Vacios Paragraph dosEspacios = new Paragraph(); dosEspacios.add(Chunk.NEWLINE); dosEspacios.add(Chunk.NEWLINE); //Hay que abrir el Documento, llenarlo con los elemntos creados //en el orden que queremos y cerrarlo document.open(); PdfContentByte cb = writer.getDirectContent(); ColumnText ct = new ColumnText(cb); Phrase recuadro = new Phrase(); recuadro.add(new Chunk("Piel de Iguana Tragos", NEGRITA_SUB_14)); recuadro.add(Chunk.NEWLINE); recuadro.add(new Chunk("Servicio de tragos para eventos", NEGRITA_12)); recuadro.add(Chunk.NEWLINE); recuadro.add(Chunk.NEWLINE); recuadro.add(new Chunk("\"Piel de Iguana, para que tu noche nica sea inigualable.\"", NORMAL_CUR_12)); recuadro.add(Chunk.NEWLINE); recuadro.add(Chunk.NEWLINE); Image logoFB = Image.getInstance("Icono FB.png"); logoFB.scaleToFit(13, 13); recuadro.add(new Chunk(logoFB, 0, -3)); recuadro.add(new Chunk("/pieldeiguanatragos.vt -> Click Aqu!", NORMAL_12)); recuadro.add(Chunk.NEWLINE); recuadro.add(Chunk.NEWLINE); recuadro.add(new Chunk("Vencimiento del Prepuesto " + General.formatoFecha.format(vtoPresup), NORMAL_SUB_12)); float llx = 279; float lly = PageSize.A4.getHeight() - 185; float ancho = 228; float alto = 150; ct.setSimpleColumn(recuadro, //Texto llx, //punta inf izquierda (x) lly, //punta inf izquierda (y) PageSize.A4.getHeight() - 185 llx + ancho, //ancho del cuadro lly + alto, // alto del cuadro 15, //espaciado Element.ALIGN_LEFT // Alineacion ); ct.go(); document.add(logoPDI); document.add(qr); document.add(dosEspacios); document.add(infoEvento); document.add(modalidadServicio); document.add(verCarta); document.add(infoContratacionTitulo); document.add(infoContratacion); document.add(despedida); document.add(firma); document.close(); System.out.println("Archivo creado"); int rta = JOptionPane.showConfirmDialog(VentanaMaestra.eventosCurrent, "Se guard el presupesto en:\n" + path + "\nDesea abrirlo?", "Presupuesto guardado", JOptionPane.YES_NO_OPTION); if (rta == JOptionPane.YES_OPTION) { if (Desktop.isDesktopSupported()) { try { File myFile = new File(path); Desktop.getDesktop().open(myFile); } catch (IOException ex) { JOptionPane.showMessageDialog(VentanaMaestra.eventosCurrent, "No se puede abrir el archivo. Ubiquelo en su equipo" + "y abralo manualmente.", "Error al abrir el archivo", JOptionPane.ERROR_MESSAGE); } } else { JOptionPane.showMessageDialog(VentanaMaestra.eventosCurrent, "No se puede abrir el archivo. Ubiquelo en su equipo" + "y abralo manualmente.", "Error al abrir el archivo", JOptionPane.ERROR_MESSAGE); } } } catch (FileNotFoundException ex) { System.out.println("Error: " + ex.toString()); } catch (DocumentException ex) { System.out.println("Error: " + ex.toString()); } catch (IOException ex) { System.out.println("Error: " + ex.toString()); } }
From source file:com.pma.mpsr.export.PDFGenerator.java
/** * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse * response)//from w ww. ja v a 2 s . c o m */ @Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String mpsrID = request.getParameter("MPSR_ID"); if (null == mpsrID) return; MPSRProjectInfo basicInfo = MPSRProjectInfo.getInstance(mpsrID); MPSRExecutiveSummary exeSummary = MPSRExecutiveSummary.getInstance(mpsrID); MPSRStatusSummary statusSummary = MPSRStatusSummary.getInstance(mpsrID); MPSRFunctionPerformance funcPerform = MPSRFunctionPerformance.getInstance(mpsrID); MPSRCostPerformance costPerform = MPSRCostPerformance.getInstance(mpsrID); MPSRSchedulePerformance[] schedulePerform = MPSRSchedulePerformance.getInstance(mpsrID); MPSRSafety safety = MPSRSafety.getInstance(mpsrID); MPSRAuthorization auth = MPSRAuthorization.getInstance(mpsrID); MPSRBudget budget = MPSRBudget.getInstance(mpsrID); MPSRCostReport[] costRpt = MPSRCostReport.getInstance(mpsrID); MPSRSchedule schedule = MPSRSchedule.getInstance(mpsrID); MPSRMilestone[] milestones = MPSRMilestone.getInstance(mpsrID); MPSRLPE lpe = MPSRLPE.getInstance(mpsrID); MPSRInsidePlantDesign[] ipds = MPSRInsidePlantDesign.getInstance(mpsrID); MPSROutsidePlantDesign[] opds = MPSROutsidePlantDesign.getInstance(mpsrID); MPSRProcure procure = MPSRProcure.getInstance(mpsrID); MPSRApprovedChanges[] approvedChanges = MPSRApprovedChanges.getInstance(mpsrID); MPSRPendingChanges[] pendingChanges = MPSRPendingChanges.getInstance(mpsrID); MPSRInsidePlantConstruction[] ipcs = MPSRInsidePlantConstruction.getInstance(mpsrID); MPSROutsidePlantConstruction[] opcs = MPSROutsidePlantConstruction.getInstance(mpsrID); MPSRAppendix[] appendixs = MPSRAppendix.getInstance(mpsrID); MPSRAttachment[] attachments = MPSRAttachment.getInstance(mpsrID); // response.setContentType("application/pdf"); // response.setHeader("Content-Disposition", // "attachment; filename=\"test.pdf\""); Font fontNormal = null; Font fontCoverTitle = new Font(FontFamily.HELVETICA, 20, Font.BOLD); Font fontCoverTableHeader = new Font(FontFamily.HELVETICA, 16, Font.BOLD); Font fontCoverTableContent = new Font(FontFamily.HELVETICA, 16); Font fontChapterHeader = new Font(FontFamily.HELVETICA, 18, Font.BOLD); Font fontSection1Header = new Font(FontFamily.HELVETICA, 16, Font.BOLD); Font fontSection2Header = new Font(FontFamily.HELVETICA, 14, Font.BOLD); Font fontWork = new Font(FontFamily.HELVETICA, 12, Font.UNDERLINE); Font fontTableCaption = new Font(FontFamily.TIMES_ROMAN, 12, Font.BOLD); Font fontTableColumnHeader = new Font(FontFamily.HELVETICA, 12, Font.BOLD); Font fontTableColumnHeaderYellow = new Font(FontFamily.HELVETICA, 12, Font.BOLD); fontTableColumnHeaderYellow.setColor(BaseColor.YELLOW); Font fontTableRowTitle = new Font(FontFamily.HELVETICA, 12, Font.ITALIC); Font fontTableCellBold = new Font(FontFamily.HELVETICA, 12, Font.BOLD); Font fontTableNote = new Font(FontFamily.HELVETICA, 10, Font.ITALIC); Font fontImageCaption = new Font(FontFamily.TIMES_ROMAN, 9, Font.BOLD); Font fontPOTableHeader = new Font(FontFamily.HELVETICA, 10, Font.BOLD); fontPOTableHeader.setColor(BaseColor.YELLOW); Font fontPOTable = new Font(FontFamily.HELVETICA, 9); Font fontPOTableSummary = new Font(FontFamily.HELVETICA, 9, Font.BOLD); Font fontPageHeader = new Font(FontFamily.HELVETICA, 8); Font fontPageFooter = new Font(FontFamily.HELVETICA, 10); Phrase[] headerTexts = new Phrase[] { new Phrase("PMA - ELECTRIC DELIVERY", fontPageHeader), new Phrase("DELIVERY PROJECTS & CONSTRUCTION (DP&C)", fontPageHeader), new Phrase("PROJECT MONTHLY REPORT", fontPageHeader) }; Paragraph paragraph = null; PdfPTable table = null; PdfPCell cell = null; Document document = new Document(DEFAULT_PAGE_SIZE, 36, 36, 9 * 10, 36); ByteArrayOutputStream baosOrig = new ByteArrayOutputStream(); XMLWorkerHelper xmlWorker = XMLWorkerHelper.getInstance(); try { PdfWriter writer = PdfWriter.getInstance(document, baosOrig); writer.setStrictImageSequence(true); writer.setLinearPageMode(); writer.setViewerPreferences(PdfWriter.PageModeUseOutlines | PdfWriter.FitWindow); Image icon = getEmbeddedImage(getServletContext(), "/resource/image/pma.bmp"); document.open(); PdfOutline root = writer.getRootOutline(); // *******************************************************************************************// // addOutline(root, writer, MPSRUI.TREE_0); for (int i = 0; i < 2; i++) { document.add(new Paragraph(" ")); } String[] titles = { "PMA DELIVERY PROJECTS & CONSTRUCTION", "MONTHLY REPORT", basicInfo.getReportMonthYear(), basicInfo.getProjectTitle(), "PROJECT No. " + basicInfo.getProjectDefinition() }; int[] spaceingAfters = { 48, 48, 48, 24, 48 }; for (int i = 0; i < titles.length; i++) { paragraph = new Paragraph(); paragraph.setSpacingAfter(spaceingAfters[i]); paragraph.setFont(fontCoverTitle); paragraph.setAlignment(Element.ALIGN_CENTER); paragraph.add(new Chunk(titles[i])); document.add(paragraph); } addCoverImage(document, MPSRUI.getFilePath(mpsrID, basicInfo.getFileName())); document.add(new Paragraph(" ")); table = new PdfPTable(2); table.addCell(new Phrase("Client", fontCoverTableHeader)); table.addCell(new Phrase(basicInfo.getProjectManager(), fontCoverTableContent)); table.addCell(new Phrase("Location", fontCoverTableHeader)); table.addCell(new Phrase(basicInfo.getProjectDirector(), fontCoverTableContent)); document.add(table); // *******************************************************************************************// document.resetPageCount(); document.add(Chunk.NEXTPAGE); writer.setPageEvent(new MPSRPageEventHelper(icon, headerTexts, fontPageFooter)); // *******************************************************************************************// PdfOutline outline1 = addOutline(root, writer, MPSRUI.TREE_1); addSectionTitle(document, MPSRUI.TREE_1, fontChapterHeader, 0, 0, 12); PdfOutline outline2 = addOutline(outline1, writer, "1.1"); addOutline(outline2, writer, MPSRUI.TREE_1_1_1); addSectionTitle(document, MPSRUI.TREE_1_1_1, fontSection2Header, 12, 12, 0); addParagraph(document, writer, xmlWorker, exeSummary.getDesc_1_1_1(), fontNormal, 12, 0, 12); addOutline(outline2, writer, MPSRUI.TREE_1_1_2); addSectionTitle(document, MPSRUI.TREE_1_1_2, fontSection2Header, 12, 12, 0); addParagraph(document, writer, xmlWorker, exeSummary.getDesc_1_1_2(), fontNormal, 12, 0, 12); addOutline(outline2, writer, MPSRUI.TREE_1_1_3); addSectionTitle(document, MPSRUI.TREE_1_1_3, fontSection2Header, 12, 12, 0); addParagraph(document, writer, xmlWorker, exeSummary.getDesc_1_1_3(), fontNormal, 12, 0, 12); addOutline(outline2, writer, MPSRUI.TREE_1_1_4); addSectionTitle(document, MPSRUI.TREE_1_1_4, fontSection2Header, 12, 12, 0); addParagraph(document, writer, xmlWorker, exeSummary.getDesc_1_1_4(), fontNormal, 12, 0, 12); // *******************************************************************************************// // 1.2 Status Summary // *******************************************************************************************// outline2 = addOutline(outline1, writer, MPSRUI.TREE_1_2); addSectionTitle(document, MPSRUI.TREE_1_2, fontSection1Header, 6, 12, 12); paragraph = new Paragraph(); paragraph.add(basicInfo.getProjectTitle()); paragraph.setSpacingAfter(4); document.add(paragraph); table = new PdfPTable(5); table.setTotalWidth(500); table.setLockedWidth(true); table.setWidths(new int[] { 3, 1, 1, 1, 1 }); cell = new PdfPCell( new Phrase("Project #: " + basicInfo.getProjectDefinition(), fontTableColumnHeader)); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); String[] headers = { "Status", "Approved (Include RnC)", "To Date", "At Completion" }; for (String header : headers) { cell = new PdfPCell(new Phrase(header, fontTableColumnHeader)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); } String[][] cellValues = { { "Budget ($M)", statusSummary.getBudgetStatus(), !"".equals(statusSummary.getBudgetApproved()) ? CURRENCY_FORMATTER .format(Double.parseDouble(statusSummary.getBudgetApproved())) : "", !"".equals(statusSummary.getBudgetToDate()) ? CURRENCY_FORMATTER.format(Double.parseDouble(statusSummary.getBudgetToDate())) : "", !"".equals(statusSummary.getBudgetAtCompletion()) ? CURRENCY_FORMATTER .format(Double.parseDouble(statusSummary.getBudgetAtCompletion())) : "" }, { "Schedule - Duration (months)", statusSummary.getScheduleStatus(), statusSummary.getScheduleApproved(), statusSummary.getScheduleToDate(), statusSummary.getScheduleAtCompletion() }, { "In-Service Date", statusSummary.getInServiceDateStatus(), statusSummary.getInServiceDateApproved(), statusSummary.getInServiceDateToDate(), statusSummary.getInServiceDateAtCompletion() } }; for (int i = 0; i < cellValues.length; i++) { table.addCell(new Phrase(cellValues[i][0])); cell = new PdfPCell(new Phrase(cellValues[i][1])); cell.setBackgroundColor(getBackgroundColor(cellValues[i][1])); cell.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(cell); for (int j = 2; j < 5; j++) { cell = new PdfPCell(new Phrase(cellValues[i][j])); cell.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(cell); } } document.add(table); // -------------------------------------------------------------------// paragraph = new Paragraph("Legend:"); paragraph.setSpacingAfter(4); paragraph.setIndentationLeft(25); document.add(paragraph); table = new PdfPTable(3); table.setTotalWidth(240); table.setLockedWidth(true); table.setHorizontalAlignment(Element.ALIGN_LEFT); String[] legends = { "On Target", "At Risk", "Off Target" }; for (String legend : legends) { cell = new PdfPCell(new Phrase(legend)); cell.setBackgroundColor(getBackgroundColor(legend)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); cell.setMinimumHeight(18); cell.setPadding(0); table.addCell(cell); } paragraph = new Paragraph(); paragraph.add(table); paragraph.setIndentationLeft(25); document.add(paragraph); // *******************************************************************************************// // 1.2.1 Functional Area Performance Indicators // *******************************************************************************************// addOutline(outline2, writer, MPSRUI.TREE_1_2_1); addSectionTitle(document, MPSRUI.TREE_1_2_1, fontSection2Header, 12, 12, 12); table = new PdfPTable(4); table.setTotalWidth(550); table.setLockedWidth(true); table.setWidths(new int[] { 4, 1, 1, 4 }); headers = new String[] { "Activities", "Current Status", "Trend", "Comments (main performance drives)" }; for (String header : headers) { cell = new PdfPCell(new Phrase(header, fontTableColumnHeader)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); } Image imgArrowUp = getEmbeddedImage(getServletContext(), "/VAADIN/themes/MPSR/img/Arrow_Up.png"); Image imgArrowDown = getEmbeddedImage(getServletContext(), "/VAADIN/themes/MPSR/img/Arrow_Down.png"); Image imgArrowEven = getEmbeddedImage(getServletContext(), "/VAADIN/themes/MPSR/img/Arrow_Even.png"); Image[] images = { imgArrowUp, imgArrowDown, imgArrowEven }; for (Image image : images) { image.scaleToFit(12, 12); } cellValues = new String[][] { { "Project - " + basicInfo.getProjectTitle(), funcPerform.getProjectStatus(), funcPerform.getProjectTrend(), funcPerform.getProjectComment() }, { " Target Budget", funcPerform.getTargetBudgetStatus(), funcPerform.getTargetBudgetTrend(), funcPerform.getTargetBudgetComment() }, { " Safety", funcPerform.getSafetyStatus(), funcPerform.getSafetyTrend(), funcPerform.getSafetyComment() }, { " Licensing & Permitting", funcPerform.getLicensingStatus(), funcPerform.getLicensingTrend(), funcPerform.getLicensingComment() }, { " Corporate Properties", funcPerform.getCorporateStatus(), funcPerform.getCorporateTrend(), funcPerform.getCorporateComment() }, { " Inside Plant Design & Engineering", funcPerform.getIPDEStatus(), funcPerform.getIPDETrend(), funcPerform.getIPDEComment() }, { " Public Outreach", funcPerform.getOutreachStatus(), funcPerform.getOutreachTrend(), funcPerform.getOutreachComment() }, { " Procurement", funcPerform.getProcureStatus(), funcPerform.getProcureTrend(), funcPerform.getProcureComment() }, { " Construction", funcPerform.getConstructionStatus(), funcPerform.getConstructionTrend(), funcPerform.getConstructionComment() }, { " Environmental - Resource Recovery", funcPerform.getEnviromentStatus(), funcPerform.getEnviromentTrend(), funcPerform.getEnviromentComment() }, { " Salvage", funcPerform.getSalvageStatus(), funcPerform.getSalvageTrend(), funcPerform.getSalvageComment() }, { " Withdrawal", funcPerform.getWithdrawalStatus(), funcPerform.getWithdrawalTrend(), funcPerform.getWithdrawalComment() } }; for (int i = 0; i < cellValues.length; i++) { cell = new PdfPCell(new Phrase(cellValues[i][0])); cell.setHorizontalAlignment(Element.ALIGN_LEFT); table.addCell(cell); cell = new PdfPCell(new Phrase(cellValues[i][1])); cell.setBackgroundColor(getBackgroundColor(cellValues[i][1])); cell.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(cell); if ("Up".equals(cellValues[i][2])) { cell = new PdfPCell(imgArrowUp); } else if ("Down".equals(cellValues[i][2])) { cell = new PdfPCell(imgArrowDown); } else if ("Even".equals(cellValues[i][2])) { cell = new PdfPCell(imgArrowEven); } else { cell = new PdfPCell(); } cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); cell = new PdfPCell(new Phrase(cellValues[i][3])); cell.setHorizontalAlignment(Element.ALIGN_LEFT); table.addCell(cell); } document.add(table); // *******************************************************************************************// document.setPageSize(DEFAULT_PAGE_SIZE.rotate()); document.add(Chunk.NEXTPAGE); addOutline(outline2, writer, MPSRUI.TREE_1_2_2); addSectionTitle(document, MPSRUI.TREE_1_2_2, fontSection2Header, 12, 12, 12); addImage(document, MPSRUI.getFilePath(mpsrID, costPerform.getFileName())); // *******************************************************************************************// // 1.2.3 Schedule Performance // *******************************************************************************************// document.add(Chunk.NEXTPAGE); addOutline(outline2, writer, MPSRUI.TREE_1_2_3); addSectionTitle(document, MPSRUI.TREE_1_2_3, fontSection2Header, 12, 12, 12); table = new PdfPTable(9); table.setTotalWidth(750); table.setLockedWidth(true); table.setWidths(new int[] { 3, 1, 1, 1, 1, 1, 1, 1, 1 }); table.setHorizontalAlignment(Element.ALIGN_CENTER); headers = new String[] { "WBS", "Original Duration", "Remaining Duration", "Baseline Start Date", "Baseline Finish Date", "Start Date", "Finish Date", "Total Float", "Status" }; for (String header : headers) { cell = new PdfPCell(new Phrase(header, fontTableColumnHeaderYellow)); cell.setBackgroundColor(BaseColor.BLUE); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); } for (int i = 0; i < schedulePerform.length; i++) { cell = new PdfPCell(new Phrase(schedulePerform[i].getWBS())); cell.setHorizontalAlignment(Element.ALIGN_LEFT); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); cell = new PdfPCell(new Phrase(Double.toString(schedulePerform[i].getOriginalDuration()))); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); cell = new PdfPCell(new Phrase(Double.toString(schedulePerform[i].getRemainingDuration()))); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); cell = new PdfPCell(new Phrase(schedulePerform[i].getPlannedStartDate())); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); cell = new PdfPCell(new Phrase(schedulePerform[i].getPlannedFinishDate())); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); cell = new PdfPCell(new Phrase(schedulePerform[i].getStartDate())); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); cell = new PdfPCell(new Phrase(schedulePerform[i].getFinishDate())); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); cell = new PdfPCell(new Phrase(schedulePerform[i].getTotalFloat())); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); cell = new PdfPCell(new Phrase(schedulePerform[i].getStatus())); cell.setHorizontalAlignment(Element.ALIGN_LEFT); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); } table.setHeaderRows(1); document.add(table); // *******************************************************************************************// // 1.3 Project Change Control // *******************************************************************************************// document.setPageSize(DEFAULT_PAGE_SIZE); document.add(Chunk.NEXTPAGE); outline2 = addOutline(outline1, writer, MPSRUI.TREE_1_3); addSectionTitle(document, MPSRUI.TREE_1_3, fontSection1Header, 6, 12, 12); addOutline(outline2, writer, MPSRUI.TREE_1_3_1); addSectionTitle(document, MPSRUI.TREE_1_3_1, fontSection2Header, 12, 12, 0); addParagraph(document, writer, xmlWorker, exeSummary.getDesc_1_3_1(), fontNormal, 12, 0, 12); addOutline(outline2, writer, MPSRUI.TREE_1_3_2); addSectionTitle(document, MPSRUI.TREE_1_3_2, fontSection2Header, 12, 12, 0); addParagraph(document, writer, xmlWorker, exeSummary.getDesc_1_3_2(), fontNormal, 12, 0, 12); // *******************************************************************************************// // 2 Safety // *******************************************************************************************// addOutline(root, writer, MPSRUI.TREE_2); addSectionTitle(document, MPSRUI.TREE_2, fontChapterHeader, 0, 24, 12); addParagraph(document, writer, xmlWorker, safety.getDesc1(), fontNormal, 12, 0, 12); paragraph = new Paragraph("Table 2.1 Project Safety Summary", fontTableCaption); paragraph.setAlignment(Element.ALIGN_CENTER); paragraph.setSpacingAfter(6); document.add(paragraph); table = new PdfPTable(3); table.setTotalWidth(300); table.setLockedWidth(true); table.setWidths(new int[] { 1, 1, 1 }); table.setHorizontalAlignment(Element.ALIGN_RIGHT); cell = new PdfPCell(new Phrase("Total Work Hours", fontTableColumnHeaderYellow)); cell.setColspan(3); cell.setBackgroundColor(BaseColor.BLUE); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); headers = new String[] { "Current Period", "Calendar YTD", "Project To Date" }; for (String header : headers) { cell = new PdfPCell(new Phrase(header, fontTableColumnHeader)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); } cellValues = new String[][] { { INTEGER_FORMATTER.format(safety.getTotalWorkHoursCurrent()), INTEGER_FORMATTER.format(safety.getTotalWorkHoursYTD()), INTEGER_FORMATTER.format(safety.getTotalWorkHoursPTD()) } }; for (int i = 0; i < cellValues.length; i++) { cell = new PdfPCell(new Phrase(cellValues[i][0])); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); cell = new PdfPCell(new Phrase(cellValues[i][1])); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); cell = new PdfPCell(new Phrase(cellValues[i][2], fontTableCellBold)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); } document.add(table); // ----------------------------------- table = new PdfPTable(4); table.setTotalWidth(500); table.setLockedWidth(true); table.setWidths(new int[] { 2, 1, 1, 1 }); table.setHorizontalAlignment(Element.ALIGN_RIGHT); cell = new PdfPCell(new Phrase("Incidents", fontTableColumnHeaderYellow)); cell.setColspan(4); cell.setBackgroundColor(BaseColor.BLUE); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); cellValues = new String[][] { { "OSHA Recordable", INTEGER_FORMATTER.format(safety.getOshaRecordableCurrent()), INTEGER_FORMATTER.format(safety.getOshaRecordableYTD()), INTEGER_FORMATTER.format(safety.getOshaRecordablePTD()) }, { "First Aid", INTEGER_FORMATTER.format(safety.getFirstAid1Current()), INTEGER_FORMATTER.format(safety.getFirstAid1YTD()), INTEGER_FORMATTER.format(safety.getFirstAid1PTD()) }, { "Near Miss", INTEGER_FORMATTER.format(safety.getNearMissCurrent()), INTEGER_FORMATTER.format(safety.getNearMissYTD()), INTEGER_FORMATTER.format(safety.getNearMissPTD()) }, { "First Aid", INTEGER_FORMATTER.format(safety.getFirstAid2Current()), INTEGER_FORMATTER.format(safety.getFirstAid2YTD()), INTEGER_FORMATTER.format(safety.getFirstAid2PTD()) } }; for (int i = 0; i < cellValues.length; i++) { cell = new PdfPCell(new Phrase(cellValues[i][0], fontTableRowTitle)); cell.setHorizontalAlignment(Element.ALIGN_LEFT); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); cell = new PdfPCell(new Phrase(cellValues[i][1])); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); cell = new PdfPCell(new Phrase(cellValues[i][2])); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); cell = new PdfPCell(new Phrase(cellValues[i][3], fontTableCellBold)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); } cell = new PdfPCell(new Phrase("*Note - " + safety.getNote(), fontTableNote)); cell.setColspan(4); cell.setHorizontalAlignment(Element.ALIGN_LEFT); cell.setVerticalAlignment(Element.ALIGN_TOP); table.addCell(cell); document.add(table); // *******************************************************************************************// // 3 Project Authorization // *******************************************************************************************// addOutline(root, writer, MPSRUI.TREE_3); addSectionTitle(document, MPSRUI.TREE_3, fontChapterHeader, 0, 24, 12); addParagraph(document, writer, xmlWorker, auth.getDesc1(), fontNormal, 12, 0, 12); table = new PdfPTable(10); table.setSpacingBefore(6); table.setTotalWidth(550); table.setLockedWidth(true); table.setWidths(new int[] { 3, 1, 1, 1, 1, 1, 1, 2, 1, 1 }); table.setHorizontalAlignment(Element.ALIGN_CENTER); headers = new String[] { "$ Millions", "Prior", auth.getHeaderYear0(), auth.getHeaderYear1(), auth.getHeaderYear2(), auth.getHeaderYear3(), auth.getHeaderYear4(), auth.getHeaderPostYear(), "Total", "Auth" }; for (String header : headers) { cell = new PdfPCell(new Phrase(header, fontTableColumnHeader)); cell.setBackgroundColor(BaseColor.YELLOW); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); } cellValues = new String[][] { { "Base", NUMBER_FORMATTER.format(auth.getBasePriorYear()), NUMBER_FORMATTER.format(auth.getBaseYear0()), NUMBER_FORMATTER.format(auth.getBaseYear1()), NUMBER_FORMATTER.format(auth.getBaseYear2()), NUMBER_FORMATTER.format(auth.getBaseYear3()), NUMBER_FORMATTER.format(auth.getBaseYear4()), NUMBER_FORMATTER.format(auth.getBasePostYear()), NUMBER_FORMATTER.format(auth.getBaseTotal()), "" }, { "Risk & Contingency", NUMBER_FORMATTER.format(auth.getRnCPriorYear()), NUMBER_FORMATTER.format(auth.getRnCYear0()), NUMBER_FORMATTER.format(auth.getRnCYear1()), NUMBER_FORMATTER.format(auth.getRnCYear2()), NUMBER_FORMATTER.format(auth.getRnCYear3()), NUMBER_FORMATTER.format(auth.getRnCYear4()), NUMBER_FORMATTER.format(auth.getRnCPostYear()), NUMBER_FORMATTER.format(auth.getRnCTotal()), "" }, { "Total Project " + auth.getTotalProjectDate(), NUMBER_FORMATTER.format(auth.getPriorTotal()), NUMBER_FORMATTER.format(auth.getYear0Total()), NUMBER_FORMATTER.format(auth.getYear1Total()), NUMBER_FORMATTER.format(auth.getYear2Total()), NUMBER_FORMATTER.format(auth.getYear3Total()), NUMBER_FORMATTER.format(auth.getYear4Total()), NUMBER_FORMATTER.format(auth.getPostTotal()), NUMBER_FORMATTER.format(auth.getTotalTotal()), "" }, { "Current Request " + auth.getReq0RequestDate(), NUMBER_FORMATTER.format(auth.getReq0PriorYear()), NUMBER_FORMATTER.format(auth.getReq0Year0()), NUMBER_FORMATTER.format(auth.getReq0Year1()), NUMBER_FORMATTER.format(auth.getReq0Year2()), NUMBER_FORMATTER.format(auth.getReq0Year3()), NUMBER_FORMATTER.format(auth.getReq0Year4()), NUMBER_FORMATTER.format(auth.getReq0PostYear()), NUMBER_FORMATTER.format(auth.getReq0Total()), NUMBER_FORMATTER.format(auth.getReq0Authorization()) }, { "Request Date " + auth.getReq1RequestDate(), NUMBER_FORMATTER.format(auth.getReq1PriorYear()), NUMBER_FORMATTER.format(auth.getReq1Year0()), NUMBER_FORMATTER.format(auth.getReq1Year1()), NUMBER_FORMATTER.format(auth.getReq1Year2()), NUMBER_FORMATTER.format(auth.getReq1Year3()), NUMBER_FORMATTER.format(auth.getReq1Year4()), NUMBER_FORMATTER.format(auth.getReq1PostYear()), NUMBER_FORMATTER.format(auth.getReq1Total()), NUMBER_FORMATTER.format(auth.getReq1Authorization()) }, { "Request Date " + auth.getReq2RequestDate(), NUMBER_FORMATTER.format(auth.getReq2PriorYear()), NUMBER_FORMATTER.format(auth.getReq2Year0()), NUMBER_FORMATTER.format(auth.getReq2Year1()), NUMBER_FORMATTER.format(auth.getReq2Year2()), NUMBER_FORMATTER.format(auth.getReq2Year3()), NUMBER_FORMATTER.format(auth.getReq2Year4()), NUMBER_FORMATTER.format(auth.getReq2PostYear()), NUMBER_FORMATTER.format(auth.getReq2Total()), NUMBER_FORMATTER.format(auth.getReq2Authorization()) }, { "Target Budget", "", "", "", "", "", "", "", auth.getTargetBudget(), "" } }; for (int i = 0; i < cellValues.length; i++) { cell = new PdfPCell(new Phrase(cellValues[i][0])); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); for (int j = 1; j < cellValues[i].length; j++) { cell = new PdfPCell(new Phrase(cellValues[i][j])); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); } } document.add(table); // *******************************************************************************************// // 4 Project Budget // *******************************************************************************************// addOutline(root, writer, MPSRUI.TREE_4); addSectionTitle(document, MPSRUI.TREE_4, fontChapterHeader, 0, 24, 12); addParagraph(document, writer, xmlWorker, budget.getDesc1(), fontNormal, 12, 0, 12); table = new PdfPTable(2); table.setSpacingBefore(6); table.setTotalWidth(350); table.setLockedWidth(true); table.setWidths(new int[] { 5, 2 }); table.setHorizontalAlignment(Element.ALIGN_CENTER); cellValues = new String[][] { { "Current Approved Budget (Base + RnC)", CURRENCY_FORMATTER.format(budget.getPMBudget()) + "M" }, { "Approved Phase Funding", CURRENCY_FORMATTER.format(budget.getPMActual()) + "M" }, { "Expended To Date", CURRENCY_FORMATTER.format(budget.getPMCommitment()) + "M" }, { "At Completion", CURRENCY_FORMATTER.format(budget.getPMAdditionalCost()) + "M" } }; for (int i = 0; i < cellValues.length; i++) { cell = new PdfPCell(new Phrase(cellValues[i][0])); cell.setHorizontalAlignment(Element.ALIGN_LEFT); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); cell = new PdfPCell(new Phrase(cellValues[i][1])); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); } document.add(table); // ---------------------------------------------------- // table 4.1 // ---------------------------------------------------- paragraph = new Paragraph("Table 4.1 Cost Report Summary", fontTableCaption); paragraph.setAlignment(Element.ALIGN_CENTER); paragraph.setSpacingAfter(6); document.add(paragraph); table = new PdfPTable(5); table.setTotalWidth(500); table.setLockedWidth(true); table.setWidths(new int[] { 1, 1, 1, 1, 1 }); table.setHorizontalAlignment(Element.ALIGN_CENTER); headers = new String[] { "Work Element", "Description", "Estimate", "Actual", "EAC" }; for (String header : headers) { cell = new PdfPCell(new Phrase(header, fontTableColumnHeaderYellow)); cell.setBackgroundColor(BaseColor.BLUE); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); } for (int i = 0; i < costRpt.length; i++) { cell = new PdfPCell(new Phrase(costRpt[i].getWbs())); cell.setHorizontalAlignment(Element.ALIGN_LEFT); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); cell = new PdfPCell(new Phrase(costRpt[i].getWbsDesc())); cell.setHorizontalAlignment(Element.ALIGN_LEFT); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); cell = new PdfPCell(new Phrase(formatNumberString(costRpt[i].getEstimate()))); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); cell = new PdfPCell(new Phrase(formatNumberString(costRpt[i].getActual()))); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); cell = new PdfPCell(new Phrase(formatNumberString(costRpt[i].getEAC()))); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); } document.add(table); // *******************************************************************************************// // 5 Project Schedule // *******************************************************************************************// outline1 = addOutline(root, writer, MPSRUI.TREE_5); addSectionTitle(document, MPSRUI.TREE_5, fontChapterHeader, 0, 24, 12); addOutline(outline1, writer, MPSRUI.TREE_5_1); addSectionTitle(document, MPSRUI.TREE_5_1, fontSection1Header, 6, 12, 12); addParagraph(document, writer, xmlWorker, schedule.getDesc_5_1(), fontNormal, 12, 0, 12); addOutline(outline1, writer, MPSRUI.TREE_5_2); addSectionTitle(document, MPSRUI.TREE_5_2, fontSection1Header, 6, 12, 12); addParagraph(document, writer, xmlWorker, schedule.getDesc_5_2(), fontNormal, 12, 0, 12); addOutline(outline1, writer, MPSRUI.TREE_5_3); addSectionTitle(document, MPSRUI.TREE_5_3, fontSection1Header, 6, 12, 12); addParagraph(document, writer, xmlWorker, schedule.getDesc_5_3(), fontNormal, 12, 0, 12); addOutline(outline1, writer, MPSRUI.TREE_5_4); addSectionTitle(document, MPSRUI.TREE_5_4, fontSection1Header, 6, 12, 12); addParagraph(document, writer, xmlWorker, schedule.getDesc_5_4(), fontNormal, 12, 0, 12); // ---------------------------------------------------- // table 5.1 // ---------------------------------------------------- paragraph = new Paragraph("Table 5.1 Planned Scorecard Milestones", fontTableCaption); paragraph.setAlignment(Element.ALIGN_CENTER); paragraph.setSpacingAfter(6); document.add(paragraph); table = new PdfPTable(3); table.setTotalWidth(500); table.setLockedWidth(true); table.setWidths(new int[] { 3, 1, 1 }); table.setHorizontalAlignment(Element.ALIGN_CENTER); headers = new String[] { "Milestone", "Planned Date", "Finish Date" }; for (String header : headers) { cell = new PdfPCell(new Phrase(header, fontTableColumnHeaderYellow)); cell.setBackgroundColor(BaseColor.BLUE); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); } for (int i = 0; i < milestones.length; i++) { cell = new PdfPCell(new Phrase(milestones[i].getMilestone())); cell.setHorizontalAlignment(Element.ALIGN_LEFT); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); cell = new PdfPCell(new Phrase(milestones[i].getPlannedDate())); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); cell = new PdfPCell(new Phrase(milestones[i].getFinishDate())); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); } document.add(table); // *******************************************************************************************// // 6 License & Permitting, and Environmental Status // *******************************************************************************************// outline1 = addOutline(root, writer, MPSRUI.TREE_6); addSectionTitle(document, MPSRUI.TREE_6, fontChapterHeader, 0, 24, 12); addOutline(outline1, writer, MPSRUI.TREE_6_1); addSectionTitle(document, MPSRUI.TREE_6_1, fontSection1Header, 6, 12, 12); addParagraph(document, writer, xmlWorker, lpe.getDesc_6_1(), fontNormal, 12, 0, 12); outline2 = addOutline(outline1, writer, MPSRUI.TREE_6_2); addSectionTitle(document, MPSRUI.TREE_6_2, fontSection1Header, 6, 12, 12); addOutline(outline2, writer, MPSRUI.TREE_6_2_1); addSectionTitle(document, MPSRUI.TREE_6_2_1, fontSection2Header, 12, 12, 12); addParagraph(document, writer, xmlWorker, lpe.getDesc_6_2_1(), fontNormal, 12, 0, 12); addOutline(outline2, writer, MPSRUI.TREE_6_2_2); addSectionTitle(document, MPSRUI.TREE_6_2_2, fontSection2Header, 12, 12, 12); addParagraph(document, writer, xmlWorker, lpe.getDesc_6_2_2(), fontNormal, 12, 0, 12); // *******************************************************************************************// // 7 Engineering Status // *******************************************************************************************// outline1 = addOutline(root, writer, MPSRUI.TREE_7); addSectionTitle(document, MPSRUI.TREE_7, fontChapterHeader, 0, 24, 12); addOutline(outline1, writer, MPSRUI.TREE_7_1); addSectionTitle(document, MPSRUI.TREE_7_1, fontSection1Header, 6, 12, 12); table = new PdfPTable(5); table.setTotalWidth(500); table.setLockedWidth(true); table.setWidths(new int[] { 2, 1, 1, 1, 3 }); table.setHorizontalAlignment(Element.ALIGN_CENTER); headers = new String[] { "Package", "IFR", "IFC", "Indicator", "Note" }; for (String header : headers) { cell = new PdfPCell(new Phrase(header, fontTableColumnHeaderYellow)); cell.setBackgroundColor(BaseColor.BLUE); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); } for (int i = 0; i < ipds.length; i++) { cell = new PdfPCell(new Phrase(ipds[i].getPackage())); cell.setHorizontalAlignment(Element.ALIGN_LEFT); cell.setVerticalAlignment(Element.ALIGN_TOP); table.addCell(cell); cell = new PdfPCell(new Phrase(ipds[i].getIFR())); cell.setHorizontalAlignment(Element.ALIGN_LEFT); cell.setVerticalAlignment(Element.ALIGN_TOP); table.addCell(cell); cell = new PdfPCell(new Phrase(ipds[i].getIFC())); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); cell.setVerticalAlignment(Element.ALIGN_TOP); table.addCell(cell); cell = new PdfPCell(new Phrase(ipds[i].getIndicator())); cell.setBackgroundColor(getBackgroundColor(ipds[i].getIndicator())); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_TOP); table.addCell(cell); cell = new PdfPCell(new Phrase(ipds[i].getNote())); cell.setHorizontalAlignment(Element.ALIGN_LEFT); cell.setVerticalAlignment(Element.ALIGN_TOP); table.addCell(cell); } document.add(table); // -----------------------------------------------------------------------------------// addOutline(outline1, writer, MPSRUI.TREE_7_2); addSectionTitle(document, MPSRUI.TREE_7_2, fontSection1Header, 6, 12, 12); table = new PdfPTable(5); table.setTotalWidth(500); table.setLockedWidth(true); table.setWidths(new int[] { 2, 1, 1, 1, 3 }); table.setHorizontalAlignment(Element.ALIGN_CENTER); headers = new String[] { "Package", "IFR", "IFC", "Indicator", "Note" }; for (String header : headers) { cell = new PdfPCell(new Phrase(header, fontTableColumnHeaderYellow)); cell.setBackgroundColor(BaseColor.BLUE); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); } for (int i = 0; i < opds.length; i++) { cell = new PdfPCell(new Phrase(opds[i].getPackage())); cell.setHorizontalAlignment(Element.ALIGN_LEFT); cell.setVerticalAlignment(Element.ALIGN_TOP); table.addCell(cell); cell = new PdfPCell(new Phrase(opds[i].getIFR())); cell.setHorizontalAlignment(Element.ALIGN_LEFT); cell.setVerticalAlignment(Element.ALIGN_TOP); table.addCell(cell); cell = new PdfPCell(new Phrase(opds[i].getIFC())); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); cell.setVerticalAlignment(Element.ALIGN_TOP); table.addCell(cell); cell = new PdfPCell(new Phrase(opds[i].getIndicator())); cell.setBackgroundColor(getBackgroundColor(opds[i].getIndicator())); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_TOP); table.addCell(cell); cell = new PdfPCell(new Phrase(opds[i].getNote())); cell.setHorizontalAlignment(Element.ALIGN_LEFT); cell.setVerticalAlignment(Element.ALIGN_TOP); table.addCell(cell); } document.add(table); // *******************************************************************************************// // 8 Procurement Status // *******************************************************************************************// outline1 = addOutline(root, writer, MPSRUI.TREE_8); addSectionTitle(document, MPSRUI.TREE_8, fontChapterHeader, 0, 24, 12); outline2 = addOutline(outline1, writer, MPSRUI.TREE_8_1); addSectionTitle(document, MPSRUI.TREE_8_1, fontSection1Header, 6, 12, 12); table = new PdfPTable(2); table.setTotalWidth(300); table.setLockedWidth(true); table.setWidths(new int[] { 1, 1 }); table.setHorizontalAlignment(Element.ALIGN_CENTER); cellValues = new String[][] { { "Receipted to Date", CURRENCY_FORMATTER.format(procure.getReceiptedToDate()) }, { "Open Commitments", CURRENCY_FORMATTER.format(procure.getOpenCommitment()) }, { "Total", CURRENCY_FORMATTER.format(procure.getTotalPurchaseOrder()) } }; for (int i = 0; i < cellValues.length; i++) { cell = new PdfPCell(new Phrase(cellValues[i][0])); cell.setHorizontalAlignment(Element.ALIGN_LEFT); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); cell = new PdfPCell(new Phrase(cellValues[i][1])); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); } document.add(table); addParagraph(document, writer, xmlWorker, procure.getDesc_8_1_B(), fontNormal, 12, 12, 12); outline2 = addOutline(outline1, writer, MPSRUI.TREE_8_2); addSectionTitle(document, MPSRUI.TREE_8_2, fontSection1Header, 6, 12, 12); // ---------------------------------------------------- // section 8.2.1 // ---------------------------------------------------- addOutline(outline2, writer, MPSRUI.TREE_8_2_1); addSectionTitle(document, MPSRUI.TREE_8_2_1, fontSection2Header, 12, 12, 12); addParagraph(document, writer, xmlWorker, procure.getDesc_8_2_1(), fontNormal, 12, 0, 12); table = new PdfPTable(6); table.setTotalWidth(550); table.setLockedWidth(true); table.setWidths(new int[] { 1, 2, 1, 1, 2, 1 }); table.setHorizontalAlignment(Element.ALIGN_CENTER); headers = new String[] { "Purchase Order", "Vendor", "Previous Amount", "This Month Amount", "This Month Description", "Total Amount" }; for (String header : headers) { cell = new PdfPCell(new Phrase(header, fontPOTableHeader)); cell.setBackgroundColor(BaseColor.BLUE); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); } double totalToDate = 0; for (int i = 0; i < approvedChanges.length; i++) { cell = new PdfPCell(new Phrase(approvedChanges[i].getPurchaseOrder(), fontPOTable)); cell.setHorizontalAlignment(Element.ALIGN_LEFT); cell.setVerticalAlignment(Element.ALIGN_TOP); table.addCell(cell); cell = new PdfPCell(new Phrase(approvedChanges[i].getVendor(), fontPOTable)); cell.setHorizontalAlignment(Element.ALIGN_LEFT); cell.setVerticalAlignment(Element.ALIGN_TOP); table.addCell(cell); cell = new PdfPCell( new Phrase(CURRENCY_FORMATTER.format(approvedChanges[i].getPreviousAmount()), fontPOTable)); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); cell.setVerticalAlignment(Element.ALIGN_TOP); table.addCell(cell); cell = new PdfPCell(new Phrase(CURRENCY_FORMATTER.format(approvedChanges[i].getThisMonthAmount()), fontPOTable)); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); cell.setVerticalAlignment(Element.ALIGN_TOP); table.addCell(cell); cell = new PdfPCell(new Phrase(approvedChanges[i].getThisMonthDescription(), fontPOTable)); cell.setHorizontalAlignment(Element.ALIGN_LEFT); cell.setVerticalAlignment(Element.ALIGN_TOP); table.addCell(cell); cell = new PdfPCell( new Phrase(CURRENCY_FORMATTER.format(approvedChanges[i].getTotalAmount()), fontPOTable)); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); cell.setVerticalAlignment(Element.ALIGN_TOP); table.addCell(cell); totalToDate += approvedChanges[i].getTotalAmount(); } document.add(table); table = new PdfPTable(2); table.setTotalWidth(550); table.setLockedWidth(true); table.setWidths(new int[] { 7, 1 }); table.setHorizontalAlignment(Element.ALIGN_CENTER); cell = new PdfPCell(new Phrase("Total To Date", fontPOTableSummary)); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); cell.setVerticalAlignment(Element.ALIGN_TOP); table.addCell(cell); cell = new PdfPCell(new Phrase(CURRENCY_FORMATTER.format(totalToDate), fontPOTableSummary)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_TOP); table.addCell(cell); document.add(table); // ---------------------------------------------------- // section 8.2.2 // ---------------------------------------------------- addOutline(outline2, writer, MPSRUI.TREE_8_2_2); addSectionTitle(document, MPSRUI.TREE_8_2_2, fontSection2Header, 12, 12, 12); addParagraph(document, writer, xmlWorker, procure.getDesc_8_2_2(), fontNormal, 12, 0, 12); table = new PdfPTable(6); table.setTotalWidth(550); table.setLockedWidth(true); table.setWidths(new int[] { 1, 2, 1, 1, 2, 1 }); table.setHorizontalAlignment(Element.ALIGN_CENTER); headers = new String[] { "Purchase Order", "Vendor", "Previous Amount", "This Month Amount", "This Month Description", "Total Amount" }; for (String header : headers) { cell = new PdfPCell(new Phrase(header, fontPOTableHeader)); cell.setBackgroundColor(BaseColor.BLUE); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); } totalToDate = 0; for (int i = 0; i < pendingChanges.length; i++) { cell = new PdfPCell(new Phrase(pendingChanges[i].getPurchaseOrder(), fontPOTable)); cell.setHorizontalAlignment(Element.ALIGN_LEFT); cell.setVerticalAlignment(Element.ALIGN_TOP); table.addCell(cell); cell = new PdfPCell(new Phrase(pendingChanges[i].getVendor(), fontPOTable)); cell.setHorizontalAlignment(Element.ALIGN_LEFT); cell.setVerticalAlignment(Element.ALIGN_TOP); table.addCell(cell); cell = new PdfPCell( new Phrase(CURRENCY_FORMATTER.format(pendingChanges[i].getPreviousAmount()), fontPOTable)); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); cell.setVerticalAlignment(Element.ALIGN_TOP); table.addCell(cell); cell = new PdfPCell( new Phrase(CURRENCY_FORMATTER.format(pendingChanges[i].getThisMonthAmount()), fontPOTable)); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); cell.setVerticalAlignment(Element.ALIGN_TOP); table.addCell(cell); cell = new PdfPCell(new Phrase(pendingChanges[i].getThisMonthDescription(), fontPOTable)); cell.setHorizontalAlignment(Element.ALIGN_LEFT); cell.setVerticalAlignment(Element.ALIGN_TOP); table.addCell(cell); cell = new PdfPCell( new Phrase(CURRENCY_FORMATTER.format(pendingChanges[i].getTotalAmount()), fontPOTable)); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); cell.setVerticalAlignment(Element.ALIGN_TOP); table.addCell(cell); totalToDate += pendingChanges[i].getTotalAmount(); } document.add(table); table = new PdfPTable(2); table.setTotalWidth(550); table.setLockedWidth(true); table.setWidths(new int[] { 7, 1 }); table.setHorizontalAlignment(Element.ALIGN_CENTER); cell = new PdfPCell(new Phrase("Total To Date", fontPOTableSummary)); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); cell.setVerticalAlignment(Element.ALIGN_TOP); table.addCell(cell); cell = new PdfPCell(new Phrase(CURRENCY_FORMATTER.format(totalToDate), fontPOTableSummary)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_TOP); table.addCell(cell); document.add(table); // *******************************************************************************************// // 9 Construction Status // *******************************************************************************************// outline1 = addOutline(root, writer, MPSRUI.TREE_9); addSectionTitle(document, MPSRUI.TREE_9, fontChapterHeader, 0, 24, 12); addOutline(outline1, writer, MPSRUI.TREE_9_1); addSectionTitle(document, MPSRUI.TREE_9_1, fontSection1Header, 6, 12, 12); for (int i = 0; i < ipcs.length; i++) { addParagraph(document, writer, xmlWorker, ipcs[i].getWork(), fontWork, 12, 12, 0); addParagraph(document, writer, xmlWorker, ipcs[i].getDescription(), fontNormal, 12, 0, 0); addImage(document, MPSRUI.getFilePath(mpsrID, ipcs[i].getFileName()), "Figure " + ipcs[i].getFigure() + " " + ipcs[i].getTitle(), fontImageCaption, 12, 3, 12); } // -----------------------------------------------------------------------------------------// addOutline(outline1, writer, MPSRUI.TREE_9_2); addSectionTitle(document, MPSRUI.TREE_9_2, fontSection1Header, 6, 12, 12); for (int i = 0; i < opcs.length; i++) { addParagraph(document, writer, xmlWorker, opcs[i].getWork(), fontWork, 12, 12, 0); addParagraph(document, writer, xmlWorker, opcs[i].getDescription(), fontNormal, 12, 0, 0); addImage(document, MPSRUI.getFilePath(mpsrID, opcs[i].getFileName()), "Figure " + opcs[i].getFigure() + " " + opcs[i].getTitle(), fontImageCaption, 12, 3, 12); } // *******************************************************************************************// // Appendix // *******************************************************************************************// if (appendixs.length > 0) { document.add(Chunk.NEXTPAGE); outline1 = addOutline(root, writer, MPSRUI.TREE_APPENDIX); for (int i = 0; i < appendixs.length; i++) { addOutline(outline1, writer, "Appendix " + appendixs[i].getNumber() + " " + appendixs[i].getTitle()); addSectionTitle(document, "Appendix " + appendixs[i].getNumber() + " " + appendixs[i].getTitle(), fontChapterHeader, 0, 12, 12); addParagraph(document, writer, xmlWorker, appendixs[i].getDescription(), fontNormal, 12, 0, 0); importPages(document, writer, mpsrID, appendixs[i].getFileName()); } } // *******************************************************************************************// // Attachment // *******************************************************************************************// if (attachments.length > 0) { document.setPageSize(DEFAULT_PAGE_SIZE); document.add(Chunk.NEXTPAGE); outline1 = addOutline(root, writer, MPSRUI.TREE_ATTACHMENT); for (int i = 0; i < attachments.length; i++) { addOutline(outline1, writer, "Attachment " + attachments[i].getNumber() + " " + attachments[i].getTitle()); addSectionTitle(document, "Attachment " + attachments[i].getNumber() + " " + attachments[i].getTitle(), fontChapterHeader, 0, 12, 12); addParagraph(document, writer, xmlWorker, attachments[i].getDescription(), fontNormal, 12, 0, 0); importPages(document, writer, mpsrID, attachments[i].getFileName()); } } document.close(); // *******************************************************************************************// // retrieve outline PdfReader readerOrig = new PdfReader(baosOrig.toByteArray()); // int origNumberOfPages = readerOrig.getNumberOfPages(); ColumnText ct = new ColumnText(null); ct.addElement(new Paragraph("Table of Contents", fontCoverTitle)); List<HashMap<String, Object>> bookmarkList = SimpleBookmark.getBookmark(readerOrig); fillColumnText(bookmarkList, ct, 18, 0, fontSection2Header); // generate TOC after cover page ByteArrayOutputStream baosTOC = new ByteArrayOutputStream(); PdfStamper stamperTOC = new PdfStamper(readerOrig, baosTOC); int tocPageEnd = 1; while (true) { stamperTOC.insertPage(++tocPageEnd, readerOrig.getPageSize(1)); PdfContentByte underContent = stamperTOC.getUnderContent(tocPageEnd); generatePageHeader(document, underContent, icon, headerTexts); ct.setCanvas(stamperTOC.getOverContent(tocPageEnd)); ct.setSimpleColumn(36, 36, 558, 693); if (!ColumnText.hasMoreText(ct.go())) break; } stamperTOC.close(); // change page labels PdfPageLabels labels = new PdfPageLabels(); labels.addPageLabel(1, PdfPageLabels.LOWERCASE_ROMAN_NUMERALS); labels.addPageLabel(tocPageEnd + 1, PdfPageLabels.DECIMAL_ARABIC_NUMERALS); // add labels ByteArrayOutputStream baosFinal = new ByteArrayOutputStream(); PdfReader readerTOC = new PdfReader(baosTOC.toByteArray()); // String selectPages = String.format("1-%s,%s-%s", tocPageEnd, // tocPageEnd + 1, origNumberOfPages + (tocPageEnd - 1)); // readerTOC.selectPages(selectPages); PdfStamper stamperFinal = new PdfStamper(readerTOC, baosFinal); stamperFinal.getWriter().setPageLabels(labels); stamperFinal.close(); // *******************************************************************************************// // send final PDF to browser response.setHeader("Expires", "0"); response.setHeader("Cache-Control", "must-revalidate, post-check=0, pre-check=0"); response.setHeader("Pragma", "public"); response.setContentType("application/pdf"); response.setContentLength(baosFinal.size()); OutputStream os = response.getOutputStream(); os.write(baosFinal.toByteArray()); os.flush(); os.close(); } catch (DocumentException e) { e.printStackTrace(); } }
From source file:com.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 w w. j av a 2s . c o m 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.shiyq.itext.PdfUtil.java
private static void addDescribe(Document document, String describe, FontSelector selector) throws DocumentException { Paragraph descP = new Paragraph(selector.process(describe)); descP.setAlignment(Element.ALIGN_JUSTIFIED); descP.setIndentationLeft(document.getPageSize().getRight() * 3 / 7); document.add(descP);/* w w w . j a va 2s .c o m*/ document.add(Chunk.NEWLINE); }
From source file:com.vectorprint.report.itext.style.stylers.Indent.java
License:Open Source License
@Override public <E> E style(E text, Object data) throws VectorPrintException { if (text instanceof Section) { Section cell = (Section) text;//from w ww. j a va 2 s.co m cell.setIndentationLeft(getIndentLeft()); cell.setIndentationRight(getIndentRight()); } else if (text instanceof Paragraph) { Paragraph par = (Paragraph) text; par.setIndentationLeft(getIndentLeft()); par.setIndentationRight(getIndentRight()); } else if (text instanceof List) { ((List) text).setIndentationLeft(getIndentLeft()); ((List) text).setIndentationLeft(getIndentRight()); } else if (text instanceof ListItem) { ((com.itextpdf.text.ListItem) text).setIndentationLeft(getIndentLeft()); ((com.itextpdf.text.ListItem) text).setIndentationLeft(getIndentRight()); } else if (text instanceof PdfPCell) { ((PdfPCell) text).setIndent(getIndentLeft()); } return text; }
From source file:controller.PDFGenerator.java
@Override public void GenerateDocument(Resolution doc) { String resId = "RES-IC-" + format(doc.getId()) + "-" + Calendar.getInstance().get(Calendar.YEAR); Document pdf = createDocument(resId + ".pdf"); if (pdf == null) return;/* w w w. ja v a2 s . co m*/ try { pdf.open(); Font boldFont = FontFactory.getFont(FontFactory.HELVETICA, 12, Font.BOLD); Font parFont = FontFactory.getFont(FontFactory.HELVETICA, 12, Font.NORMAL); Chunk chunk = new Chunk(doc.getTitle() + "\n\n", boldFont); Paragraph par = new Paragraph(chunk); par.setAlignment(Paragraph.ALIGN_CENTER); pdf.add(par); chunk = new Chunk(resId + "\n\n", boldFont); par = new Paragraph(chunk); par.setAlignment(Paragraph.ALIGN_CENTER); pdf.add(par); chunk = new Chunk("Atencin: ", boldFont); par = new Paragraph(chunk); chunk = new Chunk(doc.getAttention() + "\n\n", parFont); par.add(chunk); par.setAlignment(Paragraph.ALIGN_LEFT); par.setIndentationLeft((float) 3.0); pdf.add(par); chunk = new Chunk(doc.getIntro() + "\n\n", parFont); par = new Paragraph(chunk); par.setAlignment(Paragraph.ALIGN_JUSTIFIED); pdf.add(par); chunk = new Chunk((doc.isOneresult() == true ? "RESULTANDO NICO:\n" : "RESULTANDO:\n"), boldFont); par = new Paragraph(chunk); chunk = new Chunk(doc.getResult() + "\n\n", parFont); par.add(chunk); par.setAlignment(Paragraph.ALIGN_JUSTIFIED); pdf.add(par); chunk = new Chunk((doc.isOneconsideration() == true ? "CONSIDERANDO NICO:\n" : "CONSIDERANDOS:\n"), boldFont); par = new Paragraph(chunk); chunk = new Chunk(doc.getConsider() + "\n\n", parFont); par.add(chunk); par.setAlignment(Paragraph.ALIGN_JUSTIFIED); pdf.add(par); chunk = new Chunk("RESUELVO:\n", boldFont); par = new Paragraph(chunk); chunk = new Chunk(doc.getResolve() + "\n\n", parFont); par.add(chunk); par.setAlignment(Paragraph.ALIGN_JUSTIFIED); pdf.add(par); chunk = new Chunk("NOTIFIQUESE:\n", boldFont); par = new Paragraph(chunk); par.setAlignment(Paragraph.ALIGN_LEFT); pdf.add(par); chunk = new Chunk(doc.getNotify(), parFont); par = new Paragraph(chunk); par.setAlignment(Paragraph.ALIGN_LEFT); par.setIndentationLeft(250); pdf.add(par); pdf.close(); } catch (Exception ex) { System.out.println("Error writirn pdf."); } }
From source file:de.jost_net.JVerein.gui.action.SpendenbescheinigungPrintAction.java
License:Open Source License
/** * Generierung des Standard-Dokumentes zu verwenden fr Spendenbescheinigungen * ab 01.01.2013//ww w.j a v a 2 s .co m * * @param spb * Die Spendenbescheinigung aus der Datenbank * @param fileName * Der Dateiname, wohin das Dokument geschrieben werden soll * @throws IOException * @throws DocumentException */ private void generiereSpendenbescheinigungStandardAb2013(Spendenbescheinigung spb, String fileName) throws IOException, DocumentException { final File file = new File(fileName); FileOutputStream fos = new FileOutputStream(file); Map<String, Object> map = spb.getMap(null); map = new AllgemeineMap().getMap(map); boolean isSammelbestaetigung = spb.isSammelbestaetigung(); Reporter rpt = new Reporter(fos, 80, 50, 50, 50); rpt.addHeaderColumn("Aussteller (Bezeichnung und Anschrift der steuerbegnstigten Einrichtung)", Element.ALIGN_CENTER, 100, BaseColor.LIGHT_GRAY); rpt.createHeader(); rpt.addColumn("\n" + getAussteller() + "\n ", Element.ALIGN_LEFT); rpt.closeTable(); if (isSammelbestaetigung) { rpt.add("Sammelbesttigung ber " + map.get(SpendenbescheinigungVar.SPENDEART.getName()), 13); } else { rpt.add("Besttigung ber " + map.get(SpendenbescheinigungVar.SPENDEART.getName()), 13); } rpt.add("im Sinne des 10b des Einkommenssteuergesetzes an eine der in 5 Abs. 1 Nr. 9 des Krperschaftssteuergesetzes " + "bezeichneten Krperschaften, Personenvereinigungen oder Vermgensmassen\n", 10); rpt.addHeaderColumn("Name und Anschrift des Zuwendenden", Element.ALIGN_CENTER, 100, BaseColor.LIGHT_GRAY); rpt.createHeader(); rpt.addColumn((String) map.get(SpendenbescheinigungVar.EMPFAENGER.getName()), Element.ALIGN_LEFT); rpt.closeTable(); switch (spb.getSpendenart()) { case Spendenart.GELDSPENDE: rpt.addHeaderColumn("Betrag der Zuwendung -in Ziffern-", Element.ALIGN_CENTER, 100, BaseColor.LIGHT_GRAY); break; case Spendenart.SACHSPENDE: rpt.addHeaderColumn("Wert der Zuwendung -in Ziffern-", Element.ALIGN_CENTER, 100, BaseColor.LIGHT_GRAY); break; } rpt.addHeaderColumn("-in Buchstaben-", Element.ALIGN_CENTER, 250, BaseColor.LIGHT_GRAY); if (!isSammelbestaetigung) { rpt.addHeaderColumn("Tag der Zuwendung", Element.ALIGN_CENTER, 50, BaseColor.LIGHT_GRAY); } else { rpt.addHeaderColumn("Zeitraum der Sammelbesttigung", Element.ALIGN_CENTER, 75, BaseColor.LIGHT_GRAY); } rpt.createHeader(); rpt.addColumn( "*" + Einstellungen.DECIMALFORMAT.format(map.get(SpendenbescheinigungVar.BETRAG.getName())) + "*", Element.ALIGN_CENTER); rpt.addColumn((String) map.get(SpendenbescheinigungVar.BETRAGINWORTEN.getName()), Element.ALIGN_CENTER); if (!isSammelbestaetigung) { rpt.addColumn((String) map.get(SpendenbescheinigungVar.SPENDEDATUM.getName()), Element.ALIGN_CENTER); } else { rpt.addColumn((String) map.get(SpendenbescheinigungVar.SPENDENZEITRAUM.getName()), Element.ALIGN_CENTER); } rpt.closeTable(); switch (spb.getSpendenart()) { case Spendenart.SACHSPENDE: rpt.addHeaderColumn("Genaue Bezeichnung der Sachzuwendung mit Alter, Zustand, Kaufpreis usw.", Element.ALIGN_CENTER, 100, BaseColor.LIGHT_GRAY); rpt.createHeader(); rpt.addColumn(spb.getBezeichnungSachzuwendung(), Element.ALIGN_LEFT); rpt.closeTable(); switch (spb.getHerkunftSpende()) { case HerkunftSpende.BETRIEBSVERMOEGEN: rpt.add("Die Sachzuwendung stammt nach den Angaben des Zuwendenden aus dem Betriebsvermgen und ist " + "mit dem Entnahmewert (ggf. mit dem niedrigeren gemeinen Wert) bewertet.\n\n", 9); break; case HerkunftSpende.PRIVATVERMOEGEN: rpt.add("Die Sachzuwendung stammt nach den Angaben des Zuwendenden aus dem Privatvermgen.\n\n", 9); break; case HerkunftSpende.KEINEANGABEN: rpt.add("Der Zuwendende hat trotz Aufforderung keine Angaben zur Herkunft der Sachzuwendung gemacht.\n\n", 9); break; } if (spb.getUnterlagenWertermittlung()) { rpt.add("Geeignete Unterlagen, die zur Wertermittlung gedient haben, z. B. Rechnung, Gutachten, liegen vor.\n\n", 9); } } /* * Bei Sammelbesttigungen ist der Verweis auf Verzicht in der Anlage * vermerkt */ String verzicht = ""; char verzichtJa = (char) 113; // box leer char verzichtNein = (char) 53; // X if (spb.getAutocreate()) { if (!isSammelbestaetigung && spb.getSpendenart() == Spendenart.GELDSPENDE) { if (spb.getBuchungen().get(0).getVerzicht().booleanValue()) { verzichtJa = (char) 53; // X verzichtNein = (char) 113; // box leer } } } else { if (spb.getErsatzAufwendungen()) { verzichtJa = (char) 53; // X verzichtNein = (char) 113; // box leer } } if (!isSammelbestaetigung) { Paragraph p = new Paragraph(); p.setFont(Reporter.getFreeSans(9)); p.setAlignment(Element.ALIGN_LEFT); p.add(new Chunk("Es handelt sich um den Verzicht auf Erstattung von Aufwendungen: ")); p.add(new Chunk(" Ja ", Reporter.getFreeSansBold(9))); p.add(new Chunk(verzichtJa, FontFactory.getFont(FontFactory.ZAPFDINGBATS, 10))); p.add(new Chunk(" Nein ", Reporter.getFreeSansBold(9))); p.add(new Chunk(verzichtNein, FontFactory.getFont(FontFactory.ZAPFDINGBATS, 10))); p.add(new Chunk("\n\n")); rpt.add(p); } else { rpt.add(new Paragraph(" ", Reporter.getFreeSans(12))); } if (!Einstellungen.getEinstellung().getVorlaeufig()) { String txt = "Wir sind wegen " + Einstellungen.getEinstellung().getBeguenstigterzweck() + " nach dem letzten uns zugegangenen Freistellungsbescheid bzw. nach der Anlage zum Krperschaftssteuerbescheid des Finanzamtes " + Einstellungen.getEinstellung().getFinanzamt() + ", StNr. " + Einstellungen.getEinstellung().getSteuernummer() + ", vom " + new JVDateFormatTTMMJJJJ().format(Einstellungen.getEinstellung().getBescheiddatum()) + " nach 5 Abs. 1 Nr. 9 des Krperschaftsteuergesetzes von der Krperschaftsteuer und nach 3 Nr. 6 des Gewerbesteuergesetzes von der Gewerbesteuer befreit."; rpt.add(txt, 8); } else { String txt = "Wir sind wegen " + Einstellungen.getEinstellung().getBeguenstigterzweck() + " durch vorlufige Bescheinigung des Finanzamtes " + Einstellungen.getEinstellung().getFinanzamt() + ", StNr. " + Einstellungen.getEinstellung().getSteuernummer() + ", vom " + new JVDateFormatTTMMJJJJ().format(Einstellungen.getEinstellung().getBescheiddatum()) + " ab " + new JVDateFormatTTMMJJJJ().format(Einstellungen.getEinstellung().getVorlaeufigab()) + " als begnstigten Zwecken dienend anerkannt."; rpt.add(txt, 8); } rpt.add("\nEs wird besttigt, dass die Zuwendung nur zur " + Einstellungen.getEinstellung().getBeguenstigterzweck() + " verwendet wird.\n", 8); if (spb.getSpendenart() == Spendenart.GELDSPENDE) { char mitgliedBetraege = (char) 113; // box leer if (!Einstellungen.getEinstellung().getMitgliedsbetraege()) { mitgliedBetraege = (char) 53; // X } Paragraph p = new Paragraph(); p.setFont(Reporter.getFreeSans(9)); p.setAlignment(Element.ALIGN_LEFT); p.add(new Chunk("\n")); p.add(new Chunk( "Nur fr steuerbegnstigte Einrichtungen, bei denen die Mitgliedsbeitrge steuerlich nicht abziehbar sind:")); rpt.add(p); p = new Paragraph(); p.setFont(Reporter.getFreeSans(9)); p.setAlignment(Element.ALIGN_JUSTIFIED); p.setFirstLineIndent((float) -18.5); p.setIndentationLeft((float) 18.5); p.add(new Chunk(mitgliedBetraege, FontFactory.getFont(FontFactory.ZAPFDINGBATS, 10))); p.add(new Chunk( " Es wird besttigt, dass es sich nicht um einen Mitgliedsbeitrag handelt, dessen Abzug nach 10b Abs. 1 des Einkommensteuergesetzes ausgeschlossen ist.")); rpt.add(p); } if (isSammelbestaetigung) { rpt.add(new Paragraph(" ", Reporter.getFreeSans(12))); rpt.add("Es wird besttigt, dass ber die in der Gesamtsumme enthaltenen Zuwendungen keine weiteren Besttigungen, weder formelle Zuwendungsbesttigungen noch Beitragsquittungen oder hnliches ausgestellt wurden und werden.\n", 8); rpt.add("Ob es sich um den Verzicht auf Erstattung von Aufwendungen handelt, ist der Anlage zur Sammelbesttigung zu entnehmen.", 8); } else { rpt.add(new Paragraph(" ", Reporter.getFreeSans(12))); rpt.add("\n\n", 8); rpt.add("\n", 9); } rpt.add("\n\n" + Einstellungen.getEinstellung().getOrt() + ", " + new JVDateFormatTTMMJJJJ().format(spb.getBescheinigungsdatum()), 9); rpt.add("\n\n\n\n.................................................................................\nUnterschrift des Zuwendungsempfngers", 8); rpt.add("\nHinweis:", 9); rpt.add("Wer vorstzlich oder grob fahrlssig eine unrichtige Zuwendungsbesttigung erstellt oder wer veranlasst, dass " + "Zuwendungen nicht zu den in der Zuwendungsbesttigung angegebenen steuerbegnstigten Zwecken verwendet " + "werden, haftet fr die entgangene Steuer ( 10b Abs. 4 EStG, 9 Abs. 3 KStG, 9 Nr. 5 GewStG).\n\n" + "Diese Besttigung wird nicht als Nachweis fr die steuerliche Bercksichtigung der Zuwendung anerkannt, wenn das " + "Datum des Freistellungsbescheides lnger als 5 Jahre bzw. das Datum der vorlufigen Bescheinigung lnger als 3 Jahre " + "seit Ausstellung der Besttigung zurckliegt (BMF vom 15.12.1994 - BStBl I S. 884).", 8); /* Es sind mehrere Spenden fr diese Spendenbescheinigung vorhanden */ if (isSammelbestaetigung) { List<Buchung> buchungen = spb.getBuchungen(); rpt.newPage(); rpt.add(getAussteller(), 13); rpt.add(new Paragraph(" ", Reporter.getFreeSans(12))); rpt.add("Anlage zur Sammelbesttigung vom " + (String) map.get(SpendenbescheinigungVar.BESCHEINIGUNGDATUM.getName()), 11); rpt.add("fr den Zeitraum vom " + (String) map.get(SpendenbescheinigungVar.SPENDENZEITRAUM.getName()), 11); rpt.add(new Paragraph(" ", Reporter.getFreeSans(12))); /* Kopfzeile */ rpt.addHeaderColumn("Datum der\nZuwendung", Element.ALIGN_LEFT, 150, BaseColor.LIGHT_GRAY); rpt.addHeaderColumn("Art der\nZuwendung", Element.ALIGN_LEFT, 400, BaseColor.LIGHT_GRAY); rpt.addHeaderColumn("Verzicht auf die\nErstattung von Aufwendungen", Element.ALIGN_LEFT, 300, BaseColor.LIGHT_GRAY); rpt.addHeaderColumn("Betrag", Element.ALIGN_RIGHT, 150, BaseColor.LIGHT_GRAY); rpt.createHeader(); boolean printBuchungsart = Einstellungen.getEinstellung().getSpendenbescheinigungPrintBuchungsart(); /* Buchungszeilen */ for (Buchung buchung : buchungen) { rpt.addColumn(buchung.getDatum(), Element.ALIGN_RIGHT); String verwendung = ""; if (printBuchungsart) { verwendung = buchung.getBuchungsart().getBezeichnung(); } else { verwendung = buchung.getZweck(); } rpt.addColumn(verwendung, Element.ALIGN_LEFT); if (buchung.getVerzicht().booleanValue()) { verzicht = "ja"; } else { verzicht = "nein"; } rpt.addColumn(verzicht, Element.ALIGN_CENTER); rpt.addColumn(Double.valueOf(buchung.getBetrag())); } /* Summenzeile */ // String sumString = // Einstellungen.DECIMALFORMAT.format(spb.getBetrag()); rpt.addColumn("Gesamtsumme", Element.ALIGN_LEFT, BaseColor.LIGHT_GRAY); rpt.addColumn("", Element.ALIGN_LEFT, BaseColor.LIGHT_GRAY); rpt.addColumn("", Element.ALIGN_LEFT, BaseColor.LIGHT_GRAY); rpt.addColumn(Double.valueOf(spb.getBetrag())); // rpt.addColumn(sumString, Element.ALIGN_RIGHT, // BaseColor.LIGHT_GRAY); rpt.closeTable(); // // Etwas Abstand // rpt.add(new Paragraph(" ")); // // Nun noch die Legende // rpt.add("Legende:", 8); // rpt.add( // "(a): Es handelt sich nicht um den Verzicht auf Erstattung von // Aufwendungen", // 8); // rpt.add( // "(b): Es handelt sich um den Verzicht auf Erstattung von Aufwendungen", // 8); } rpt.close(); fos.close(); }