List of usage examples for com.itextpdf.text BaseColor GREEN
BaseColor GREEN
To view the source code for com.itextpdf.text BaseColor GREEN.
Click Source Link
From source file:pkgfinal.viewTable.java
private void jButton11ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton11ActionPerformed try {//from w w w.j a v a 2 s .com Document document = new Document(); PdfWriter.getInstance(document, new FileOutputStream(" " + jComboBox1.getSelectedItem() + ".pdf")); document.open(); // Image image = Image.getInstance("save.png"); // document.add(new Paragraph("image")); // document.add(image); document.add(new Paragraph("ECHO TRADERS", FontFactory.getFont(FontFactory.TIMES_ROMAN, 18, Font.BOLD, BaseColor.RED))); document.add(new Paragraph(" " + jComboBox1.getSelectedItem() + " Report ", FontFactory.getFont(FontFactory.TIMES_ROMAN, 18, Font.BOLD, BaseColor.BLUE))); document.add(new Paragraph(new java.util.Date().toString())); document.add(new Paragraph("--------------------------------------------------------")); PdfPTable table = new PdfPTable(7); PdfPCell cell = new PdfPCell(new Paragraph("Purcahse_Sale Report")); cell.setColspan(7); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setBackgroundColor(BaseColor.GREEN); table.addCell(cell); String sql = "select * from '" + jComboBox1.getSelectedItem() + "' "; pst = conn.prepareStatement(sql); rs = pst.executeQuery(); while (rs.next()) { String v1 = rs.getString("ID"); String add = rs.getString("Date"); String v2 = rs.getString("BrandName"); String v3 = rs.getString("ManufactureName"); String v4 = rs.getString("PurchaseQuantity"); String v5 = rs.getString("SaleQuantity"); String v6 = rs.getString("TotalQuantity"); // table.addCell("ID"); table.addCell(v1); // table.addCell(v/*.date_tf.getDateFormatString()*/); table.addCell(add); // table.addCell("Brand name"); table.addCell(v2); // table.addCell("Manyfacture Name"); table.addCell(v3); // table.addCell("purchase Quantity"); table.addCell(v4); table.addCell(v5); table.addCell(v6); } document.add(table); com.itextpdf.text.List list = new com.itextpdf.text.List(true, 20); list.add("Printed Date:_____________"); list.add("Signature:_______________"); document.add(list); document.close(); JOptionPane.showMessageDialog(null, "Saved Report"); } catch (Exception e) { JOptionPane.showMessageDialog(null, e); } }
From source file:reporteFertilizacion.ReporteResultadoLaboratorio.java
/** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> * methods./*ww w . ja va 2s. co m*/ * * @param request servlet request * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("application/pdf"); try { Font font9BoldWhite = FontFactory.getFont(FontFactory.HELVETICA, 9, Font.BOLD, BaseColor.WHITE); Font font7Bold = FontFactory.getFont(FontFactory.HELVETICA, 7, Font.BOLD); Font font7Normal = FontFactory.getFont(FontFactory.HELVETICA, 7, Font.NORMAL); Font font8Bold = FontFactory.getFont(FontFactory.HELVETICA, 8, Font.BOLD); Font font8Normal = FontFactory.getFont(FontFactory.HELVETICA, 8, Font.NORMAL); Font font9Bold = FontFactory.getFont(FontFactory.HELVETICA, 9, Font.BOLD); Font font9Normal = FontFactory.getFont(FontFactory.HELVETICA, 9, Font.NORMAL); Font font10Bold = FontFactory.getFont(FontFactory.HELVETICA, 10, Font.BOLD); Font font10Normal = FontFactory.getFont(FontFactory.HELVETICA, 10, Font.NORMAL); Font font12Bold = FontFactory.getFont(FontFactory.HELVETICA, 12, Font.BOLD); Font font12Normal = FontFactory.getFont(FontFactory.HELVETICA, 12, Font.NORMAL); Font font14Bold = FontFactory.getFont(FontFactory.HELVETICA, 14, Font.BOLD); Font font14Normal = FontFactory.getFont(FontFactory.HELVETICA, 14, Font.NORMAL); Font font18Bold = FontFactory.getFont(FontFactory.HELVETICA, 18, Font.BOLD); Font font22Bold = FontFactory.getFont(FontFactory.HELVETICA, 22, Font.BOLD); //obtencion parametros ********************************************************* FacesContext facesContext = FacesContext.getCurrentInstance(); Map params = facesContext.getExternalContext().getRequestParameterMap(); ObjectId parametroObtenido = new ObjectId(params.get("idMuestra").toString()); ResultadoLaboratorio resLab = ResultadoLaboratorio.getResultadoLaboratorioById(parametroObtenido); MuestraLaboratorio muestra = MuestraLaboratorio.getMuestraLaboratorioById(resLab.getMuestra()); Cliente cli = Cliente.getClienteById( Hacienda.getHaciendaById(muestra.getSiembraCultivo().getIdHacienda()).getIdCliente()); Hacienda hac = Hacienda .getHaciendaById(Hacienda.getHaciendaById(muestra.getSiembraCultivo().getIdHacienda()).getId()); //Lote lot = Lote.getLoteById(muestra.getLote()); //String lot = muestra.getLote(); Cultivo cul = Cultivo.getCultivoById(muestra.getSiembraCultivo().getIdCultivo()); String cliente = cli.getNombre().toUpperCase(); String ubicacion = Canton.getCantonById(cli.getCanton()).getNombre() + " - " + Canton.getCantonById(cli.getCanton()).getLeyendaProvincia() + " - " + Canton.getCantonById(cli.getCanton()).getLeyendaPais(); String codigMuestra = muestra.getCodigo(); String hacienda = hac.getNombre(); String cultivo = cul.getNombre(); //String varie = Variedad.getVariedadById(lot.getIdVariedad()).getNombre(); String varie = muestra.getSiembraCultivo().getLeyendaVariedad(); //String estacionMonitoreo = lot.getEstacion().get(0).getCodigo(); String estacionMonitoreo = muestra.getSiembraCultivo().getUnidadManejo(); //String estacionMonitoreo = muestra.getLoteCompleto().getListadoMonitoreo().get(0).getCodigo(); String tituloProyecto = "Anlisis" + resLab.getLeyendaMatriz(); String tipoMuestra = resLab.getLeyendaMatriz(); String numeroMuestra = Integer.toString( MuestraLaboratorio.getNumberMuestraLaboratorio(muestra.getId(), muestra.getIdSiembraCultivo())); String numeroMonitoreo = numeroMuestra; //String lote = lot.getCodigo(); String lote = ""; int nn = muestra.getSiembraCultivo().getListaLotesSiembra().size(); for (int i = 0; i < nn; i++) { lote = lote.concat(muestra.getSiembraCultivo().getListaLotesSiembra().get(i).getLeyendaLote()); } String muestreador = muestra.getMuestreador(); String fechaMuestreo = muestra.getFechaFormatMuestreo(); String fechaRecepcionMuestra = muestra.getFechaFormatEnvio(); String fechaResultado = resLab.getFechaFormatResultado(); String periodoPrueba = resLab.getFechaFormatRecepcion() + " al " + resLab.getFechaFormatResultado(); String contenidoHoja1 = TextoReporteResultadoLaboratorio.getByReferencia("HOJA 1 TEXTO INFORME") .getDescripcion(); String responsableTecnico = TextoReporteResultadoLaboratorio.getByReferencia("RESPONSABLE TECNICO") .getDescripcion(); String datosLaboratorio = TextoReporteResultadoLaboratorio.getByReferencia("DATOS LABORATORIO") .getDescripcion(); String piePagina = TextoReporteResultadoLaboratorio.getByReferencia("PIE DE PAGINA").getDescripcion(); String contenidoHoja2 = TextoReporteResultadoLaboratorio.getByReferencia("HOJA 2 OBSERVACION") .getDescripcion(); //fin obtencion parametros ***************************************************** /* TODO output your page here. You may use following sample code. */ float left = 60; float right = 30; float top = 0; float bottom = 0; Document document = new Document(PageSize.A4, left, right, top, bottom); PdfWriter writer = PdfWriter.getInstance(document, response.getOutputStream()); //FOOTER TABLE ***************************************************************** PdfPTable table = new PdfPTable(1); table.setTotalWidth(550); PdfPCell cell = new PdfPCell(new Phrase(piePagina, font8Normal)); cell.setBackgroundColor(BaseColor.GREEN); cell.setBorder(PdfPCell.NO_BORDER); table.addCell(cell); cell = new PdfPCell(new Phrase("www.agrorum.com.ec", font9BoldWhite)); cell.setBackgroundColor(BaseColor.ORANGE); cell.setBorder(PdfPCell.NO_BORDER); cell.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT); table.addCell(cell); FooterTable event = new FooterTable(table); writer.setPageEvent(event); //FIN FOOTER TABLE ***************************************************************** document.open(); //HOJA 1 ********************************************************************************************************************************* //IMAGE ********************************************************************************** String relativeWebPathAg = "/images/agrorum.png"; String absoluteDiskPathAg = getServletContext().getRealPath(relativeWebPathAg); Image logoAg = Image.getInstance(absoluteDiskPathAg); logoAg.setAbsolutePosition(10f, 750f); logoAg.scalePercent(80f); document.add(logoAg); String relativeWebPathEu = "/images/eurofins.png"; String absoluteDiskPathEu = getServletContext().getRealPath(relativeWebPathEu); Image logoEu = Image.getInstance(absoluteDiskPathEu); logoEu.setAbsolutePosition(500f, 770f); logoEu.scalePercent(60f); document.add(logoEu); //FIN IMAGE ******************************************************************************** //CLIENTE UBICACION MUESTRA***************************************************************** Paragraph parphRepor = new Paragraph("Reporte de anlisis 1/2", font10Normal); parphRepor.setAlignment(Element.ALIGN_RIGHT); parphRepor.setSpacingBefore(90f); Paragraph parphCli = new Paragraph(cliente, font10Bold); parphCli.setAlignment(Element.ALIGN_LEFT); parphCli.setSpacingBefore(15f); Paragraph parphUbi = new Paragraph(ubicacion, font10Bold); parphUbi.setAlignment(Element.ALIGN_LEFT); parphUbi.setSpacingBefore(15f); //PARRAFO combinado con frases******************************************** Phrase p1 = new Phrase("Cdigo de la Muestra: ", font10Normal); Phrase p2 = new Phrase(codigMuestra, font10Bold); Paragraph parphMue = new Paragraph(p1); parphMue.add(p2); parphMue.setAlignment(Element.ALIGN_LEFT); parphMue.setSpacingBefore(15f); //FIN PARRAFO combinado*************************************************** document.add(parphRepor); document.add(parphCli); document.add(parphUbi); document.add(parphMue); //FIN CLIENTE UBICACION MUESTRA************************************************************* //TABLA *********************************************************************************** PdfPTable tableDatos = new PdfPTable(new float[] { 0.20f, 0.80f }); tableDatos.setWidthPercentage(100); tableDatos.addCell(getCell("Propiedad:", PdfPCell.ALIGN_LEFT, font8Normal)); tableDatos.addCell(getCell(hacienda, PdfPCell.ALIGN_LEFT, font8Bold)); tableDatos.addCell(getCell("Cultivo Actual:", PdfPCell.ALIGN_LEFT, font8Normal)); tableDatos.addCell(getCell(cultivo, PdfPCell.ALIGN_LEFT, font8Bold)); tableDatos.addCell(getCell("Estacin Monitoreo:", PdfPCell.ALIGN_LEFT, font8Normal)); tableDatos.addCell(getCell(estacionMonitoreo, PdfPCell.ALIGN_LEFT, font8Bold)); tableDatos.addCell(getCell("Ttulo Proyecto:", PdfPCell.ALIGN_LEFT, font8Normal)); tableDatos.addCell(getCell(tituloProyecto, PdfPCell.ALIGN_LEFT, font8Bold)); tableDatos.addCell(getCell("Tipo Muestra:", PdfPCell.ALIGN_LEFT, font8Normal)); tableDatos.addCell(getCell(tipoMuestra, PdfPCell.ALIGN_LEFT, font8Bold)); tableDatos.addCell(getCell("Nmero Muestra:", PdfPCell.ALIGN_LEFT, font8Normal)); tableDatos.addCell(getCell(numeroMuestra, PdfPCell.ALIGN_LEFT, font8Bold)); tableDatos.addCell(getCell("Nmero Monitoreo:", PdfPCell.ALIGN_LEFT, font8Normal)); tableDatos.addCell(getCell(numeroMonitoreo, PdfPCell.ALIGN_LEFT, font8Bold)); tableDatos.addCell(getCell("Lote:", PdfPCell.ALIGN_LEFT, font8Normal)); tableDatos.addCell(getCell(lote, PdfPCell.ALIGN_LEFT, font8Bold)); tableDatos.addCell(getCell("Muestreador:", PdfPCell.ALIGN_LEFT, font8Normal)); tableDatos.addCell(getCell(muestreador.toUpperCase(), PdfPCell.ALIGN_LEFT, font8Bold)); tableDatos.addCell(getCell("Fecha Muestreo:", PdfPCell.ALIGN_LEFT, font8Normal)); tableDatos.addCell(getCell(fechaMuestreo, PdfPCell.ALIGN_LEFT, font8Bold)); tableDatos.addCell(getCell("Recepcin Muestra:", PdfPCell.ALIGN_LEFT, font8Normal)); tableDatos.addCell(getCell(fechaRecepcionMuestra, PdfPCell.ALIGN_LEFT, font8Bold)); tableDatos.addCell(getCell("Perodo de Prueba:", PdfPCell.ALIGN_LEFT, font8Normal)); tableDatos.addCell(getCell(periodoPrueba, PdfPCell.ALIGN_LEFT, font8Bold)); tableDatos.setSpacingBefore(20f); document.add(tableDatos); //FIN TABLA ******************************************************************************** //CONTENIDO ******************************************************************************** Paragraph parphCont = new Paragraph(contenidoHoja1, font8Normal); parphCont.setAlignment(Element.ALIGN_JUSTIFIED); parphCont.setSpacingBefore(20f); Paragraph parphLLeida = new Paragraph("LLeida, " + fechaResultado, font8Normal); parphLLeida.setAlignment(Element.ALIGN_LEFT); parphLLeida.setSpacingBefore(20f); Paragraph parphTecnico = new Paragraph(responsableTecnico, font9Bold); parphTecnico.setAlignment(Element.ALIGN_LEFT); parphTecnico.setSpacingBefore(20f); Paragraph parphResponsable = new Paragraph("Responsable Tcnico", font8Normal); parphResponsable.setAlignment(Element.ALIGN_LEFT); parphResponsable.setSpacingBefore(1f); Paragraph parphLaboratorio = new Paragraph(datosLaboratorio, font8Bold); parphLaboratorio.setAlignment(Element.ALIGN_LEFT); parphLaboratorio.setSpacingBefore(30f); document.add(parphCont); document.add(parphLLeida); document.add(parphTecnico); document.add(parphResponsable); document.add(parphLaboratorio); //FIN CONTENIDO **************************************************************************** //FIN HOJA 1 ***************************************************************************************************************************** document.newPage(); //HOJA 2 ********************************************************************************************************************************* //IMAGE ********************************************************************************** String relativeWebPathAg1 = "/images/agrorum.png"; String absoluteDiskPathAg1 = getServletContext().getRealPath(relativeWebPathAg1); Image logoAg1 = Image.getInstance(absoluteDiskPathAg1); logoAg1.setAbsolutePosition(10f, 750f); logoAg1.scalePercent(80f); document.add(logoAg1); String relativeWebPathEu1 = "/images/eurofins.png"; String absoluteDiskPathEu1 = getServletContext().getRealPath(relativeWebPathEu1); Image logoEu1 = Image.getInstance(absoluteDiskPathEu1); logoEu1.setAbsolutePosition(500f, 770f); logoEu1.scalePercent(60f); document.add(logoEu1); Paragraph ini = new Paragraph("", font12Bold); ini.setAlignment(Element.ALIGN_CENTER); ini.setSpacingBefore(100f); PdfPTable cabT = new PdfPTable(new float[] { 1f }); cabT.setWidthPercentage(100); PdfPCell cellCab = new PdfPCell(new Phrase("Informe de Prueba", font12Bold)); cellCab.setPadding(2f); cellCab.setHorizontalAlignment(Element.ALIGN_CENTER); cabT.addCell(cellCab); Paragraph parphRep = new Paragraph("Reporte de anlisis 2/2", font10Normal); parphRep.setAlignment(Element.ALIGN_RIGHT); document.add(ini); document.add(cabT); document.add(parphRep); //TABLA *********************************************************************************** PdfPTable tableDatosH2 = new PdfPTable(new float[] { 0.20f, 0.80f }); tableDatosH2.setWidthPercentage(100); tableDatosH2.addCell(getCell("Cliente:", PdfPCell.ALIGN_LEFT, font8Normal)); tableDatosH2.addCell(getCell(cliente, PdfPCell.ALIGN_LEFT, font8Bold)); tableDatosH2.addCell(getCell(" ", PdfPCell.ALIGN_LEFT, font8Normal)); tableDatosH2.addCell(getCell(" ", PdfPCell.ALIGN_LEFT, font8Bold)); tableDatosH2.addCell(getCell("Propiedad:", PdfPCell.ALIGN_LEFT, font8Normal)); tableDatosH2.addCell(getCell(hacienda, PdfPCell.ALIGN_LEFT, font8Bold)); tableDatosH2.addCell(getCell("Estacin Monitoreo:", PdfPCell.ALIGN_LEFT, font8Normal)); tableDatosH2.addCell(getCell(estacionMonitoreo, PdfPCell.ALIGN_LEFT, font8Bold)); tableDatosH2.addCell(getCell("Nmero Monitoreo:", PdfPCell.ALIGN_LEFT, font8Normal)); tableDatosH2.addCell(getCell(numeroMuestra, PdfPCell.ALIGN_LEFT, font8Bold)); tableDatosH2.addCell(getCell("Codigo Muestra:", PdfPCell.ALIGN_LEFT, font8Normal)); tableDatosH2.addCell(getCell(codigMuestra, PdfPCell.ALIGN_LEFT, font8Bold)); tableDatosH2.addCell(getCell("Matriz:", PdfPCell.ALIGN_LEFT, font8Normal)); tableDatosH2.addCell(getCell(tipoMuestra, PdfPCell.ALIGN_LEFT, font8Bold)); tableDatosH2.addCell(getCell("Cultivo:", PdfPCell.ALIGN_LEFT, font8Normal)); tableDatosH2.addCell(getCell(cultivo, PdfPCell.ALIGN_LEFT, font8Bold)); tableDatosH2.addCell(getCell("Variedad:", PdfPCell.ALIGN_LEFT, font8Normal)); tableDatosH2.addCell(getCell(varie, PdfPCell.ALIGN_LEFT, font8Bold)); tableDatosH2.addCell(getCell("Fecha Muestreo:", PdfPCell.ALIGN_LEFT, font8Normal)); tableDatosH2.addCell(getCell(fechaMuestreo, PdfPCell.ALIGN_LEFT, font8Bold)); tableDatosH2.addCell(getCell("Recepcin Muestra:", PdfPCell.ALIGN_LEFT, font8Normal)); tableDatosH2.addCell(getCell(fechaRecepcionMuestra, PdfPCell.ALIGN_LEFT, font8Bold)); tableDatosH2.addCell(getCell("Perodo de Prueba:", PdfPCell.ALIGN_LEFT, font8Normal)); tableDatosH2.addCell(getCell(periodoPrueba, PdfPCell.ALIGN_LEFT, font8Bold)); tableDatosH2.setSpacingBefore(20f); document.add(tableDatosH2); //FIN TABLA ******************************************************************************** Paragraph parphCont1 = new Paragraph(contenidoHoja2, font8Normal); parphCont1.setAlignment(Element.ALIGN_JUSTIFIED); parphCont1.setSpacingBefore(20f); PdfPTable tableDatosH3 = new PdfPTable(new float[] { 0.30f, 0.70f }); tableDatosH3.setWidthPercentage(100); tableDatosH3.addCell(getCell(datosLaboratorio, PdfPCell.ALIGN_LEFT, font8Bold)); PdfPTable subTable = new PdfPTable(new float[] { 1f }); subTable.setWidthPercentage(100); subTable.addCell(getCell("LLeida, " + fechaResultado, PdfPCell.ALIGN_CENTER, font8Normal)); subTable.addCell(getCell(" ", PdfPCell.ALIGN_CENTER, font8Normal)); subTable.addCell(getCell(" ", PdfPCell.ALIGN_CENTER, font8Normal)); subTable.addCell(getCell(" ", PdfPCell.ALIGN_CENTER, font8Normal)); subTable.addCell(getCell(responsableTecnico, PdfPCell.ALIGN_CENTER, font9Bold)); subTable.addCell(getCell("Responsable Tcnico", PdfPCell.ALIGN_CENTER, font8Normal)); PdfPCell cellsub = new PdfPCell(subTable); cellsub.setBorder(PdfPCell.NO_BORDER); cellsub.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); tableDatosH3.addCell(cellsub); tableDatosH3.setSpacingBefore(20f); document.add(parphCont1); document.add(tableDatosH3); //FIN IMAGE ******************************************************************************** //FIN HOJA 2 ***************************************************************************************************************************** document.close(); } catch (DocumentException de) { throw new IOException(de.getMessage()); } }
From source file:servlet.SalesReportPDF.java
/** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> * methods.// www . j ava2 s.c o m * * @param request servlet request * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { try { Document document = new Document(); List<ArrayList> data = productSession.getEventList(); List<ArrayList> sessions = getAllProductDetailsLocal.getAllSessions(); DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss"); //get current date time with Date() Date date = new Date(); //System.out.println(dateFormat.format(date)); @SuppressWarnings("unused") PdfWriter pdfWriter = PdfWriter.getInstance(document, new FileOutputStream("C:/Users/Yong Jing Ying/Desktop/EventRecords.pdf")); document.open(); document.add(new Paragraph("Management Report", FontFactory.getFont(FontFactory.TIMES_BOLD, 18, Font.BOLD, BaseColor.BLUE))); document.add(new Paragraph("PDF created on " + dateFormat.format(date).toString() + "\n", FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, BaseColor.BLACK))); document.add(new Paragraph( "------------------------------------------------------------------------------------", FontFactory.getFont(FontFactory.TIMES_BOLD, 18, Font.BOLD, BaseColor.BLACK))); for (int i = 0; i < data.size(); i++) { document.add(new Paragraph(data.get(i).get(1).toString() + " Event Details ", FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, BaseColor.BLACK))); document.add(new Paragraph("Event Type : " + data.get(i).get(4).toString() + "\nStart Date : " + data.get(i).get(2).toString() + "\nEnd Date : " + data.get(i).get(3).toString() + "\nProperty Name : " + data.get(i).get(5).toString() + "\nNo of Category : " + data.get(i).get(6).toString() + "\nPromotions : " + data.get(i).get(7).toString() + "\n\n")); document.add(new Paragraph("Session", FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, BaseColor.BLACK))); PdfPTable table = new PdfPTable(6); //table.addCell("item1"); table.setSpacingBefore(5); table.setSpacingAfter(5); table.setWidths(new int[] { 1, 2, 3, 3, 3, 3 }); table.setWidthPercentage(100); PdfPCell cell; cell = new PdfPCell(new Phrase("No:", FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, BaseColor.BLACK))); cell.setBackgroundColor(BaseColor.CYAN); table.addCell(cell); cell = new PdfPCell(new Phrase("Name:", FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, BaseColor.BLACK))); cell.setBackgroundColor(BaseColor.CYAN); table.addCell(cell); cell = new PdfPCell(new Phrase("Description:", FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, BaseColor.BLACK))); cell.setBackgroundColor(BaseColor.CYAN); table.addCell(cell); cell = new PdfPCell(new Phrase("Start:", FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, BaseColor.BLACK))); cell.setBackgroundColor(BaseColor.CYAN); table.addCell(cell); cell = new PdfPCell(new Phrase("End:", FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, BaseColor.BLACK))); cell.setBackgroundColor(BaseColor.CYAN); table.addCell(cell); cell = new PdfPCell(new Phrase("TicketPrices:", FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, BaseColor.BLACK))); cell.setBackgroundColor(BaseColor.CYAN); table.addCell(cell); for (int j = 0; j < sessions.size(); j++) { if (sessions.get(j).get(1).toString().equals(data.get(i).get(4).toString()) && sessions.get(j).get(0).toString().equals(data.get(i).get(0).toString())) { cell = new PdfPCell(new Phrase(sessions.get(j).get(8).toString())); cell.setBackgroundColor(BaseColor.WHITE); table.addCell(cell); cell = new PdfPCell(new Phrase(sessions.get(j).get(4).toString())); cell.setBackgroundColor(BaseColor.WHITE); table.addCell(cell); cell = new PdfPCell(new Phrase(sessions.get(j).get(5).toString())); cell.setBackgroundColor(BaseColor.WHITE); table.addCell(cell); cell = new PdfPCell(new Phrase(sessions.get(j).get(6).toString())); cell.setBackgroundColor(BaseColor.WHITE); table.addCell(cell); cell = new PdfPCell(new Phrase(sessions.get(j).get(7).toString())); cell.setBackgroundColor(BaseColor.WHITE); table.addCell(cell); cell = new PdfPCell(new Phrase(sessions.get(j).get(9).toString())); cell.setBackgroundColor(BaseColor.WHITE); table.addCell(cell); } } document.add(table); document.add(new Paragraph("\n")); document.add(new Paragraph("Alert", FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, BaseColor.BLACK))); table = new PdfPTable(6); //table.addCell("item1"); table.setSpacingBefore(5); table.setSpacingAfter(5); table.setWidths(new int[] { 1, 2, 2, 3, 3, 3 }); table.setWidthPercentage(100); cell = new PdfPCell(new Phrase("No:", FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, BaseColor.BLACK))); cell.setBackgroundColor(BaseColor.GREEN); table.addCell(cell); cell = new PdfPCell(new Phrase("Alert Type:", FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, BaseColor.BLACK))); cell.setBackgroundColor(BaseColor.GREEN); table.addCell(cell); cell = new PdfPCell(new Phrase("Below Sales:", FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, BaseColor.BLACK))); cell.setBackgroundColor(BaseColor.GREEN); table.addCell(cell); cell = new PdfPCell(new Phrase("In-Charged Email:", FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, BaseColor.BLACK))); cell.setBackgroundColor(BaseColor.GREEN); table.addCell(cell); cell = new PdfPCell(new Phrase("Start:", FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, BaseColor.BLACK))); cell.setBackgroundColor(BaseColor.GREEN); table.addCell(cell); cell = new PdfPCell(new Phrase("End:", FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, BaseColor.BLACK))); cell.setBackgroundColor(BaseColor.GREEN); table.addCell(cell); for (int j = 0; j < sessions.size(); j++) { if (sessions.get(j).get(1).toString().equals(data.get(i).get(4).toString()) && sessions.get(j).get(0).toString().equals(data.get(i).get(0).toString()) && sessions.get(j).size() == 15) { cell = new PdfPCell(new Phrase(sessions.get(j).get(8).toString())); cell.setBackgroundColor(BaseColor.WHITE); table.addCell(cell); cell = new PdfPCell(new Phrase(sessions.get(j).get(10).toString())); cell.setBackgroundColor(BaseColor.WHITE); table.addCell(cell); cell = new PdfPCell(new Phrase(sessions.get(j).get(11).toString())); cell.setBackgroundColor(BaseColor.WHITE); table.addCell(cell); cell = new PdfPCell(new Phrase(sessions.get(j).get(12).toString())); cell.setBackgroundColor(BaseColor.WHITE); table.addCell(cell); cell = new PdfPCell(new Phrase(sessions.get(j).get(13).toString())); cell.setBackgroundColor(BaseColor.WHITE); table.addCell(cell); cell = new PdfPCell(new Phrase(sessions.get(j).get(14).toString())); cell.setBackgroundColor(BaseColor.WHITE); table.addCell(cell); } } document.add(table); document.add(new Paragraph("\n\n")); } document.close(); Thread.sleep(1000); PrintWriter out = response.getWriter(); String fileName = "EventRecords.pdf"; String filePath = "C:/Users/Yong Jing Ying/Desktop/"; response.setContentType("APPLICATION/OCTET-STREAM"); response.setHeader("Content-Disposition", "attachment;filename=\"" + fileName + "\""); FileInputStream fi = new FileInputStream("C:/Users/Yong Jing Ying/Desktop/EventRecords.pdf"); int i; while ((i = fi.read()) != -1) { out.write(i); } out.close(); fi.close(); } catch (Exception ex) { Logger.getLogger(SalesReportPDF.class.getName()).log(Level.SEVERE, null, ex); } }