List of usage examples for com.itextpdf.text BaseColor ORANGE
BaseColor ORANGE
To view the source code for com.itextpdf.text BaseColor ORANGE.
Click Source Link
From source file:org.cejug.yougi.web.report.EventAttendeeReport.java
License:Open Source License
public void printReport(List<Attendee> attendees) throws DocumentException { float[] columnSizes = { 20, 220, 220, 60 }; PdfPTable table = new PdfPTable(columnSizes.length); table.setLockedWidth(true);//from www . ja v a 2 s. co m table.setTotalWidth(columnSizes); PdfPCell headerCell = new PdfPCell(new Phrase("Yougi")); headerCell.setColspan(4); headerCell.setBackgroundColor(BaseColor.ORANGE); headerCell.setPadding(3); table.addCell(headerCell); table.getDefaultCell().setBackgroundColor(BaseColor.LIGHT_GRAY); PdfPCell checkCell = new PdfPCell(new Phrase(" ")); checkCell.setBackgroundColor(BaseColor.LIGHT_GRAY); table.addCell(checkCell); PdfPCell productCell = new PdfPCell(new Phrase("Nome")); productCell.setBackgroundColor(BaseColor.LIGHT_GRAY); productCell.setVerticalAlignment(Element.ALIGN_BOTTOM); table.addCell(productCell); PdfPCell currentPurchaseCell = new PdfPCell(new Phrase("Email")); currentPurchaseCell.setPadding(3); currentPurchaseCell.setHorizontalAlignment(Element.ALIGN_CENTER); currentPurchaseCell.setBackgroundColor(BaseColor.LIGHT_GRAY); table.addCell(currentPurchaseCell); PdfPCell previousPurchaseCell = new PdfPCell(new Phrase("Presente")); previousPurchaseCell.setPadding(3); previousPurchaseCell.setHorizontalAlignment(Element.ALIGN_CENTER); previousPurchaseCell.setBackgroundColor(BaseColor.LIGHT_GRAY); table.addCell(previousPurchaseCell); table.getDefaultCell().setBackgroundColor(null); table.setHeaderRows(2); Font font = new Font(Font.FontFamily.HELVETICA, 9); int seq = 1; for (Attendee attendee : attendees) { table.addCell(new Phrase(String.valueOf(seq++), font)); table.addCell(new Phrase(attendee.getUserAccount().getFullName(), font)); table.addCell(new Phrase(attendee.getUserAccount().getEmail(), font)); table.addCell(" "); } document.add(table); }
From source file:presentation.frmReportForm.java
private void btnGenerateActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnGenerateActionPerformed Date dateNow = new Date(); SimpleDateFormat df = new SimpleDateFormat("dd_MM_yyyy_HH_mm_ss"); System.out.println(dtcMonthChooser.getMonth()); System.out.println(dtcYearChooser.getYear()); if (radInMonth.isSelected()) { List<Transfer> transferList = new ArrayList<>(); transferList = empObj.searchRecordByMonth(dtcMonthChooser.getMonth() + 1, dtcYearChooser.getYear()); Document document = new Document(); try {//w w w.j av a2 s. c o m Font fontTitle = new Font(FontFamily.HELVETICA, 20, Font.BOLD); String fileName = "../EMPtranfermanagement/Report" + " " + df.format(dateNow) + ".pdf"; PdfWriter.getInstance(document, new FileOutputStream(fileName)); document.open(); Image imageLogo = Image .getInstance(this.getClass().getResource("/images/onlinelogomaker-afterscale2.png")); imageLogo.setAbsolutePosition(20, 750f); document.add(imageLogo); Paragraph titlePara = new Paragraph("EMP Transfer Application", fontTitle); titlePara.setAlignment(Element.ALIGN_CENTER); titlePara.setSpacingAfter(5); document.add(titlePara); Paragraph creditPara = new Paragraph("Created by Ly Thanh Hai + Nguyen Khanh", FontFactory.getFont(FontFactory.HELVETICA, 10, Font.ITALIC)); creditPara.setAlignment(Element.ALIGN_CENTER); creditPara.setSpacingAfter(10); document.add(creditPara); Paragraph slashPara = new Paragraph( "Transfer records at " + (dtcMonthChooser.getMonth() + 1) + "/" + dtcYearChooser.getYear(), FontFactory.getFont(FontFactory.HELVETICA, 15, Font.BOLD)); slashPara.setSpacingAfter(40); slashPara.setAlignment(Element.ALIGN_CENTER); document.add(slashPara); PdfPTable table = new PdfPTable(5); table.setWidthPercentage(100); Font font = new Font(FontFamily.HELVETICA, 15, Font.BOLD); Paragraph paragraphCellHeading = new Paragraph("Report", font); PdfPCell cellHeading = new PdfPCell(paragraphCellHeading); BaseColor myColor = WebColors.getRGBColor("#41a5c2"); cellHeading.setColspan(5); cellHeading.setBackgroundColor(myColor); cellHeading.setFixedHeight(30.3f); cellHeading.setVerticalAlignment(Element.ALIGN_MIDDLE); cellHeading.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(cellHeading); Font fBody = new Font(FontFamily.HELVETICA, 13, Font.NORMAL, GrayColor.BLACK); PdfPCell cellTitle1 = new PdfPCell(new Phrase("Transfer ID", fBody)); cellTitle1.setVerticalAlignment(Element.ALIGN_MIDDLE); cellTitle1.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(cellTitle1); PdfPCell cellTitle2 = new PdfPCell(new Phrase("Emp ID", fBody)); cellTitle2.setVerticalAlignment(Element.ALIGN_MIDDLE); cellTitle2.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(cellTitle2); PdfPCell cellTitle3 = new PdfPCell(new Phrase("From Project", fBody)); cellTitle3.setVerticalAlignment(Element.ALIGN_MIDDLE); cellTitle3.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(cellTitle3); PdfPCell cellTitle4 = new PdfPCell(new Phrase("To Project", fBody)); cellTitle4.setVerticalAlignment(Element.ALIGN_MIDDLE); cellTitle4.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(cellTitle4); PdfPCell cellTitleStatus = new PdfPCell(new Phrase("Status", fBody)); cellTitleStatus.setVerticalAlignment(Element.ALIGN_MIDDLE); cellTitleStatus.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(cellTitleStatus); int cellColorCheck = 1; for (Transfer e : transferList) { PdfPCell cellBody1 = new PdfPCell(new Phrase(e.getId())); PdfPCell cellBody2 = new PdfPCell(new Phrase(e.getEmployeeId())); PdfPCell cellBody3 = new PdfPCell(new Phrase(e.getFromProjectId())); PdfPCell cellBody4 = new PdfPCell(new Phrase(e.getToProjectId())); PdfPCell cellBody5 = new PdfPCell(new Phrase(e.getStatus())); if (cellColorCheck % 2 == 1) { cellBody1.setBackgroundColor(BaseColor.ORANGE); cellBody2.setBackgroundColor(BaseColor.ORANGE); cellBody3.setBackgroundColor(BaseColor.ORANGE); cellBody4.setBackgroundColor(BaseColor.ORANGE); cellBody5.setBackgroundColor(BaseColor.ORANGE); } table.addCell(cellBody1); table.addCell(cellBody2); table.addCell(cellBody3); table.addCell(cellBody4); table.addCell(cellBody5); cellColorCheck++; } document.add(table); JOptionPane.showMessageDialog(this, "Report saved"); if (Desktop.isDesktopSupported()) { File reportFile = new File(fileName); Desktop.getDesktop().open(reportFile); ; } document.close(); } catch (DocumentException | FileNotFoundException ex) { Logger.getLogger(frmReportForm.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(frmReportForm.class.getName()).log(Level.SEVERE, null, ex); } } if (radInDateRange.isSelected()) { try { List<Transfer> transferList = new ArrayList<>(); java.sql.Date fromDateSql = formatDateForSearching(dtcFromDate.getDate()); java.sql.Date toDateSql = formatDateForSearching(dtcToDate.getDate()); transferList = empObj.searchRecordByDate(fromDateSql, toDateSql); Document document = new Document(); try { Font fontTitle = new Font(FontFamily.HELVETICA, 20, Font.BOLD); String fileName = "../EMPtranfermanagement/Report" + " " + df.format(dateNow) + ".pdf"; PdfWriter.getInstance(document, new FileOutputStream(fileName)); document.open(); Image imageLogo = Image .getInstance(this.getClass().getResource("/images/onlinelogomaker-afterscale2.png")); imageLogo.setAbsolutePosition(20, 750f); document.add(imageLogo); Paragraph titlePara = new Paragraph("EMP Transfer Application", fontTitle); titlePara.setAlignment(Element.ALIGN_CENTER); titlePara.setSpacingAfter(5); document.add(titlePara); Paragraph creditPara = new Paragraph("Created by Ly Thanh Hai + Nguyen Khanh", FontFactory.getFont(FontFactory.HELVETICA, 10, Font.ITALIC)); creditPara.setAlignment(Element.ALIGN_CENTER); creditPara.setSpacingAfter(10); document.add(creditPara); SimpleDateFormat df2 = new SimpleDateFormat("dd/MM/yyyy"); String fromDate = df2.format(dtcFromDate.getDate()); String toDate = df2.format(dtcToDate.getDate()); Paragraph slashPara = new Paragraph("Transfer records from " + fromDate + " to " + toDate, FontFactory.getFont(FontFactory.HELVETICA, 15, Font.BOLD)); slashPara.setSpacingAfter(40); slashPara.setAlignment(Element.ALIGN_CENTER); document.add(slashPara); PdfPTable table = new PdfPTable(5); table.setWidthPercentage(100); Font font = new Font(FontFamily.HELVETICA, 15, Font.BOLD); Paragraph paragraphCellHeading = new Paragraph("Report", font); PdfPCell cellHeading = new PdfPCell(paragraphCellHeading); BaseColor myColor = WebColors.getRGBColor("#41a5c2"); cellHeading.setColspan(5); cellHeading.setBackgroundColor(myColor); cellHeading.setFixedHeight(30.3f); cellHeading.setVerticalAlignment(Element.ALIGN_MIDDLE); cellHeading.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(cellHeading); Font fBody = new Font(FontFamily.HELVETICA, 13, Font.NORMAL, GrayColor.BLACK); PdfPCell cellTitle1 = new PdfPCell(new Phrase("Transfer ID", fBody)); cellTitle1.setVerticalAlignment(Element.ALIGN_MIDDLE); cellTitle1.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(cellTitle1); PdfPCell cellTitle2 = new PdfPCell(new Phrase("Emp ID", fBody)); cellTitle2.setVerticalAlignment(Element.ALIGN_MIDDLE); cellTitle2.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(cellTitle2); PdfPCell cellTitle3 = new PdfPCell(new Phrase("From Project", fBody)); cellTitle3.setVerticalAlignment(Element.ALIGN_MIDDLE); cellTitle3.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(cellTitle3); PdfPCell cellTitle4 = new PdfPCell(new Phrase("To Project", fBody)); cellTitle4.setVerticalAlignment(Element.ALIGN_MIDDLE); cellTitle4.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(cellTitle4); PdfPCell cellTitleStatus = new PdfPCell(new Phrase("Status", fBody)); cellTitleStatus.setVerticalAlignment(Element.ALIGN_MIDDLE); cellTitleStatus.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(cellTitleStatus); int cellColorCheck = 1; for (Transfer e : transferList) { PdfPCell cellBody1 = new PdfPCell(new Phrase(e.getId())); PdfPCell cellBody2 = new PdfPCell(new Phrase(e.getEmployeeId())); PdfPCell cellBody3 = new PdfPCell(new Phrase(e.getFromProjectId())); PdfPCell cellBody4 = new PdfPCell(new Phrase(e.getToProjectId())); PdfPCell cellBody5 = new PdfPCell(new Phrase(e.getStatus())); if (cellColorCheck % 2 == 1) { cellBody1.setBackgroundColor(BaseColor.ORANGE); cellBody2.setBackgroundColor(BaseColor.ORANGE); cellBody3.setBackgroundColor(BaseColor.ORANGE); cellBody4.setBackgroundColor(BaseColor.ORANGE); cellBody5.setBackgroundColor(BaseColor.ORANGE); } table.addCell(cellBody1); table.addCell(cellBody2); table.addCell(cellBody3); table.addCell(cellBody4); table.addCell(cellBody5); cellColorCheck++; } document.add(table); JOptionPane.showMessageDialog(this, "Report saved"); if (Desktop.isDesktopSupported()) { File reportFile = new File(fileName); Desktop.getDesktop().open(reportFile); ; } document.close(); } catch (DocumentException | FileNotFoundException ex) { Logger.getLogger(frmReportForm.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(frmReportForm.class.getName()).log(Level.SEVERE, null, ex); } } catch (ParseException ex) { Logger.getLogger(frmReportForm.class.getName()).log(Level.SEVERE, null, ex); } } if (radInProject.isSelected()) { String fromProjectId = (String) cbxFromProject.getSelectedItem(); String toProjectId = (String) cbxToProject.getSelectedItem(); List<Transfer> transferList = new ArrayList<>(); String andOr = ""; if (cbxAndOr.getSelectedItem().equals("And")) { andOr = "and"; transferList = empObj.searchRecordByFromAndToProject(fromProjectId, toProjectId, andOr); } else { andOr = "or"; transferList = empObj.searchRecordByFromAndToProject(fromProjectId, toProjectId, andOr); } Document document = new Document(); try { Font fontTitle = new Font(FontFamily.HELVETICA, 20, Font.BOLD); String fileName = "../EMPtranfermanagement/Report" + " " + df.format(dateNow) + ".pdf"; PdfWriter.getInstance(document, new FileOutputStream(fileName)); document.open(); Image imageLogo = Image .getInstance(this.getClass().getResource("/images/onlinelogomaker-afterscale2.png")); imageLogo.setAbsolutePosition(20, 750f); document.add(imageLogo); Paragraph titlePara = new Paragraph("EMP Transfer Application", fontTitle); titlePara.setAlignment(Element.ALIGN_CENTER); titlePara.setSpacingAfter(5); document.add(titlePara); Paragraph creditPara = new Paragraph("Created by Ly Thanh Hai + Nguyen Khanh", FontFactory.getFont(FontFactory.HELVETICA, 10, Font.ITALIC)); creditPara.setAlignment(Element.ALIGN_CENTER); creditPara.setSpacingAfter(10); document.add(creditPara); Paragraph slashPara = new Paragraph( "Transfer records from Project ID " + fromProjectId + " " + andOr + " " + toProjectId, FontFactory.getFont(FontFactory.HELVETICA, 15, Font.BOLD)); slashPara.setSpacingAfter(40); slashPara.setAlignment(Element.ALIGN_CENTER); document.add(slashPara); PdfPTable table = new PdfPTable(5); table.setWidthPercentage(100); Font font = new Font(FontFamily.HELVETICA, 15, Font.BOLD); Paragraph paragraphCellHeading = new Paragraph("Report", font); PdfPCell cellHeading = new PdfPCell(paragraphCellHeading); BaseColor myColor = WebColors.getRGBColor("#41a5c2"); cellHeading.setColspan(5); cellHeading.setBackgroundColor(myColor); cellHeading.setFixedHeight(30.3f); cellHeading.setVerticalAlignment(Element.ALIGN_MIDDLE); cellHeading.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(cellHeading); Font fBody = new Font(FontFamily.HELVETICA, 13, Font.NORMAL, GrayColor.BLACK); PdfPCell cellTitle1 = new PdfPCell(new Phrase("Transfer ID", fBody)); cellTitle1.setVerticalAlignment(Element.ALIGN_MIDDLE); cellTitle1.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(cellTitle1); PdfPCell cellTitle2 = new PdfPCell(new Phrase("Emp ID", fBody)); cellTitle2.setVerticalAlignment(Element.ALIGN_MIDDLE); cellTitle2.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(cellTitle2); PdfPCell cellTitle3 = new PdfPCell(new Phrase("From Project", fBody)); cellTitle3.setVerticalAlignment(Element.ALIGN_MIDDLE); cellTitle3.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(cellTitle3); PdfPCell cellTitle4 = new PdfPCell(new Phrase("To Project", fBody)); cellTitle4.setVerticalAlignment(Element.ALIGN_MIDDLE); cellTitle4.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(cellTitle4); PdfPCell cellTitleStatus = new PdfPCell(new Phrase("Status", fBody)); cellTitleStatus.setVerticalAlignment(Element.ALIGN_MIDDLE); cellTitleStatus.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(cellTitleStatus); int cellColorCheck = 1; for (Transfer e : transferList) { PdfPCell cellBody1 = new PdfPCell(new Phrase(e.getId())); PdfPCell cellBody2 = new PdfPCell(new Phrase(e.getEmployeeId())); PdfPCell cellBody3 = new PdfPCell(new Phrase(e.getFromProjectId())); PdfPCell cellBody4 = new PdfPCell(new Phrase(e.getToProjectId())); PdfPCell cellBody5 = new PdfPCell(new Phrase(e.getStatus())); if (cellColorCheck % 2 == 1) { cellBody1.setBackgroundColor(BaseColor.ORANGE); cellBody2.setBackgroundColor(BaseColor.ORANGE); cellBody3.setBackgroundColor(BaseColor.ORANGE); cellBody4.setBackgroundColor(BaseColor.ORANGE); cellBody5.setBackgroundColor(BaseColor.ORANGE); } table.addCell(cellBody1); table.addCell(cellBody2); table.addCell(cellBody3); table.addCell(cellBody4); table.addCell(cellBody5); cellColorCheck++; } document.add(table); JOptionPane.showMessageDialog(this, "Report saved"); if (Desktop.isDesktopSupported()) { File reportFile = new File(fileName); Desktop.getDesktop().open(reportFile); ; } document.close(); } catch (DocumentException | FileNotFoundException ex) { Logger.getLogger(frmReportForm.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(frmReportForm.class.getName()).log(Level.SEVERE, null, ex); } } if (radAllRecord.isSelected()) { List<Transfer> transferList = new ArrayList<>(); transferList = empObj.searchAllRecord(); Document document = new Document(); try { Font fontTitle = new Font(FontFamily.HELVETICA, 20, Font.BOLD); String fileName = "../EMPtranfermanagement/Report" + " " + df.format(dateNow) + ".pdf"; PdfWriter.getInstance(document, new FileOutputStream(fileName)); document.open(); Image imageLogo = Image .getInstance(this.getClass().getResource("/images/onlinelogomaker-afterscale2.png")); imageLogo.setAbsolutePosition(20, 750f); document.add(imageLogo); Paragraph titlePara = new Paragraph("EMP Transfer Application", fontTitle); titlePara.setAlignment(Element.ALIGN_CENTER); titlePara.setSpacingAfter(5); document.add(titlePara); Paragraph creditPara = new Paragraph("Created by Ly Thanh Hai + Nguyen Khanh", FontFactory.getFont(FontFactory.HELVETICA, 10, Font.ITALIC)); creditPara.setAlignment(Element.ALIGN_CENTER); creditPara.setSpacingAfter(10); document.add(creditPara); Paragraph slashPara = new Paragraph("All transfer records", FontFactory.getFont(FontFactory.HELVETICA, 15, Font.BOLD)); slashPara.setSpacingAfter(40); slashPara.setAlignment(Element.ALIGN_CENTER); document.add(slashPara); PdfPTable table = new PdfPTable(5); table.setWidthPercentage(100); Font font = new Font(FontFamily.HELVETICA, 15, Font.BOLD); Paragraph paragraphCellHeading = new Paragraph("Report", font); PdfPCell cellHeading = new PdfPCell(paragraphCellHeading); BaseColor myColor = WebColors.getRGBColor("#41a5c2"); cellHeading.setColspan(5); cellHeading.setBackgroundColor(myColor); cellHeading.setFixedHeight(30.3f); cellHeading.setVerticalAlignment(Element.ALIGN_MIDDLE); cellHeading.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(cellHeading); Font fBody = new Font(FontFamily.HELVETICA, 13, Font.NORMAL, GrayColor.BLACK); PdfPCell cellTitle1 = new PdfPCell(new Phrase("Transfer ID", fBody)); cellTitle1.setVerticalAlignment(Element.ALIGN_MIDDLE); cellTitle1.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(cellTitle1); PdfPCell cellTitle2 = new PdfPCell(new Phrase("Emp ID", fBody)); cellTitle2.setVerticalAlignment(Element.ALIGN_MIDDLE); cellTitle2.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(cellTitle2); PdfPCell cellTitle3 = new PdfPCell(new Phrase("From Project", fBody)); cellTitle3.setVerticalAlignment(Element.ALIGN_MIDDLE); cellTitle3.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(cellTitle3); PdfPCell cellTitle4 = new PdfPCell(new Phrase("To Project", fBody)); cellTitle4.setVerticalAlignment(Element.ALIGN_MIDDLE); cellTitle4.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(cellTitle4); PdfPCell cellTitleStatus = new PdfPCell(new Phrase("Status", fBody)); cellTitleStatus.setVerticalAlignment(Element.ALIGN_MIDDLE); cellTitleStatus.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(cellTitleStatus); int cellColorCheck = 1; for (Transfer e : transferList) { PdfPCell cellBody1 = new PdfPCell(new Phrase(e.getId())); PdfPCell cellBody2 = new PdfPCell(new Phrase(e.getEmployeeId())); PdfPCell cellBody3 = new PdfPCell(new Phrase(e.getFromProjectId())); PdfPCell cellBody4 = new PdfPCell(new Phrase(e.getToProjectId())); PdfPCell cellBody5 = new PdfPCell(new Phrase(e.getStatus())); if (cellColorCheck % 2 == 1) { cellBody1.setBackgroundColor(BaseColor.ORANGE); cellBody2.setBackgroundColor(BaseColor.ORANGE); cellBody3.setBackgroundColor(BaseColor.ORANGE); cellBody4.setBackgroundColor(BaseColor.ORANGE); cellBody5.setBackgroundColor(BaseColor.ORANGE); } table.addCell(cellBody1); table.addCell(cellBody2); table.addCell(cellBody3); table.addCell(cellBody4); table.addCell(cellBody5); cellColorCheck++; } document.add(table); JOptionPane.showMessageDialog(this, "Report saved"); if (Desktop.isDesktopSupported()) { File reportFile = new File(fileName); Desktop.getDesktop().open(reportFile); ; } document.close(); } catch (DocumentException | FileNotFoundException ex) { Logger.getLogger(frmReportForm.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(frmReportForm.class.getName()).log(Level.SEVERE, null, ex); } } }
From source file:reporteFertilizacion.ReporteResultadoLaboratorio.java
/** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> * methods.//from w ww . j av a 2 s .com * * @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:ServletsReportesPDF.ReporteRiegos.java
/** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> * methods./*from ww w . j a v a 2 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 { response.setContentType("text/html;charset=UTF-8"); String num_lote = request.getParameter("num_lote"); response.setContentType("application/pdf"); OutputStream out = response.getOutputStream(); try { try { Connection con = null; Statement st = null; Statement st2 = null; Statement st3 = null; Statement st4 = null; ResultSet rs = null; ResultSet rs2 = null; ResultSet rs3 = null; ResultSet rs4 = null; Class.forName("com.mysql.jdbc.Driver"); con = (Connection) DriverManager.getConnection("jdbc:mysql://localhost:3306/simpca", "root", "9510"); st = (Statement) con.createStatement(); st2 = (Statement) con.createStatement(); st3 = (Statement) con.createStatement(); st4 = (Statement) con.createStatement(); rs = st.executeQuery( "SELECT usuario.cedula,nombre,apellido,telefono FROM usuario JOIN lote ON lote.usuario_cedula=usuario.cedula WHERE lote.num_lote='" + num_lote + "'"); rs2 = st2.executeQuery("SELECT * from riego where num_lote ='" + num_lote + "'"); rs3 = st3.executeQuery("SELECT * from riego where num_lote ='" + num_lote + "'"); rs4 = st4.executeQuery("SELECT * from riego where num_lote ='" + num_lote + "'"); if (con != null) { Document documento = new Document(A4.rotate()); PdfWriter writer = PdfWriter.getInstance(documento, out); FooterPiePaginaiText footer = new FooterPiePaginaiText(); writer.setPageEvent(footer); documento.open(); try { Image imagenes = Image.getInstance( "C:\\Users\\USUARIO\\Desktop\\simpca\\SIMPCA Coagronorte\\web\\ImagenesR\\coagronorte-slogan.png"); imagenes.setAlignment(Element.ALIGN_RIGHT); imagenes.scaleToFit(200, 200); documento.add(imagenes); //documento.add(imagenes); Paragraph par21 = new Paragraph(); Font fontDescrip = new Font(Font.FontFamily.TIMES_ROMAN, 20, Font.ITALIC, BaseColor.BLACK); par21.add(new Phrase("Cooperativa Agropecuaria de Norte de Santander", fontDescrip)); par21.setAlignment(Element.ALIGN_CENTER); par21.add(new Phrase(Chunk.NEWLINE)); documento.add(par21); String nombre = null; String Apellido = null; String cedula = null; while (rs.next()) { nombre = (rs.getString("nombre")); cedula = (rs.getString("cedula")); Apellido = (rs.getString("apellido")); } Paragraph par2 = new Paragraph(); Font fontfecha = new Font(Font.FontFamily.TIMES_ROMAN, 13, Font.NORMAL, BaseColor.BLACK); Date date = new Date(); DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy "); par2.add(new Paragraph("Fecha: " + dateFormat.format(date), fontfecha)); //par2.add(new Paragraph(new Date().toString())); par2.setAlignment(Element.ALIGN_RIGHT); ; documento.add(par2); Paragraph par7 = new Paragraph(); Font fontUsuario = new Font(Font.FontFamily.TIMES_ROMAN, 14, Font.NORMAL, BaseColor.BLACK); par7.add(new Phrase("Nombre: " + nombre + " " + Apellido, fontUsuario)); par7.add(new Phrase("\nc.c: " + cedula, fontUsuario)); par7.setAlignment(Element.ALIGN_LEFT); par7.add(new Phrase(Chunk.NEWLINE)); documento.add(par7); Paragraph par3 = new Paragraph(); Font fontDescri = new Font(Font.FontFamily.TIMES_ROMAN, 16, Font.NORMAL, BaseColor.BLACK); par3.add(new Phrase("Numero Lote:\n " + num_lote, fontDescri)); par3.setAlignment(Element.ALIGN_CENTER); par3.add(new Phrase(Chunk.NEWLINE)); documento.add(par3); } catch (Exception eX) { eX.getMessage(); } try { Paragraph par1 = new Paragraph(); Font fonttitulo = new Font(Font.FontFamily.TIMES_ROMAN, 16, Font.BOLD, BaseColor.BLACK); par1.add(new Phrase(Chunk.NEWLINE)); par1.add(new Phrase(Chunk.NEWLINE)); par1.add(new Phrase(Chunk.NEWLINE)); par1.add(new Phrase("REPORTE RIEGOS", fonttitulo)); par1.setAlignment(Element.ALIGN_CENTER); par1.add(new Phrase(Chunk.NEWLINE)); documento.add(par1); PdfPTable tabla = new PdfPTable(5); FontFactory.registerDirectories(); documento.add(new Paragraph("\n")); PdfPCell celda1 = new PdfPCell(new Paragraph("Fecha", FontFactory.getFont("Times New Roman", 12, Font.BOLD, BaseColor.BLACK))); PdfPCell celda2 = new PdfPCell(new Paragraph("Tipo de Riego", FontFactory.getFont("Times New Roman", 12, Font.BOLD, BaseColor.BLACK))); PdfPCell celda3 = new PdfPCell(new Paragraph("Cantidad Mano Obra", FontFactory.getFont("Times New Roman", 12, Font.BOLD, BaseColor.BLACK))); PdfPCell celda4 = new PdfPCell(new Paragraph("Valor Mano Obra", FontFactory.getFont("Times New Roman", 12, Font.BOLD, BaseColor.BLACK))); PdfPCell celda5 = new PdfPCell(new Paragraph("Valor Total Mano Obra", FontFactory.getFont("Times New Roman", 12, Font.BOLD, BaseColor.BLACK))); tabla.addCell(celda1); tabla.addCell(celda2); tabla.addCell(celda3); tabla.addCell(celda4); tabla.addCell(celda5); while (rs2.next()) { tabla.addCell(rs2.getString("fecha_riego")); tabla.addCell(rs2.getString("tipo_riego")); tabla.addCell(rs2.getString("cantidad_mano_obra_riego")); tabla.addCell(rs2.getString("valor_mano_obra_riego")); tabla.addCell(rs2.getString("total_mano_obra")); } documento.add(tabla); Paragraph par4 = new Paragraph(); par4.add(new Phrase(Chunk.NEWLINE)); par4.add(new Phrase(Chunk.NEWLINE)); par4.add(new Phrase(Chunk.NEWLINE)); Font fontFooter2 = new Font(Font.FontFamily.TIMES_ROMAN, 16, Font.BOLD, BaseColor.BLACK); par4.add(new Phrase("REPORTE INSUMOS RIEGO", fontFooter2)); par4.setAlignment(Element.ALIGN_CENTER); par4.add(new Phrase(Chunk.NEWLINE)); par4.add(new Phrase(Chunk.NEWLINE)); documento.add(par4); PdfPTable tabla2 = new PdfPTable(7); FontFactory.registerDirectories(); PdfPCell celda10 = new PdfPCell(new Paragraph("Tipo de Riego", FontFactory.getFont("Times New Roman", 12, Font.BOLD, BaseColor.BLACK))); celda10.setHorizontalAlignment(Element.ALIGN_CENTER); PdfPCell celda20 = new PdfPCell(new Paragraph("Cantidad Aceite", FontFactory.getFont("Times New Roman", 12, Font.BOLD, BaseColor.BLACK))); celda20.setHorizontalAlignment(Element.ALIGN_CENTER); PdfPCell celda30 = new PdfPCell(new Paragraph("Valor Aceite", FontFactory.getFont("Times New Roman", 12, Font.BOLD, BaseColor.BLACK))); celda30.setHorizontalAlignment(Element.ALIGN_CENTER); PdfPCell celda40 = new PdfPCell(new Paragraph("Valor Total Aceite", FontFactory.getFont("Times New Roman", 12, Font.BOLD, BaseColor.BLACK))); celda40.setHorizontalAlignment(Element.ALIGN_CENTER); PdfPCell celda50 = new PdfPCell(new Paragraph("Cantidad Combustible", FontFactory.getFont("Times New Roman", 12, Font.BOLD, BaseColor.BLACK))); celda50.setHorizontalAlignment(Element.ALIGN_CENTER); PdfPCell celda60 = new PdfPCell(new Paragraph("Valor Combustible", FontFactory.getFont("Times New Roman", 12, Font.BOLD, BaseColor.BLACK))); celda60.setHorizontalAlignment(Element.ALIGN_CENTER); PdfPCell celda70 = new PdfPCell(new Paragraph("Valor Total Combustible", FontFactory.getFont("Times New Roman", 12, Font.BOLD, BaseColor.BLACK))); celda70.setHorizontalAlignment(Element.ALIGN_CENTER); tabla2.addCell(celda10); tabla2.addCell(celda20); tabla2.addCell(celda30); tabla2.addCell(celda40); tabla2.addCell(celda50); tabla2.addCell(celda60); tabla2.addCell(celda70); while (rs3.next()) { tabla2.addCell(rs3.getString("tipo_riego")); tabla2.addCell(rs3.getString("cantidad_aceite")); tabla2.addCell(rs3.getString("valor_aceite")); tabla2.addCell(rs3.getString("total_aceite")); tabla2.addCell(rs3.getString("cantidad_combustible")); tabla2.addCell(rs3.getString("valor_combustible")); tabla2.addCell(rs3.getString("total_combustible_riego")); } documento.add(tabla2); Paragraph par8 = new Paragraph(); par8.add(new Phrase(Chunk.NEWLINE)); par8.add(new Phrase(Chunk.NEWLINE)); par8.add(new Phrase(Chunk.NEWLINE)); Font fontFooter4 = new Font(Font.FontFamily.TIMES_ROMAN, 16, Font.BOLD, BaseColor.ORANGE); par8.add(new Phrase("REPORTE COSTOS ADICIONALES", fontFooter4)); par8.setAlignment(Element.ALIGN_CENTER); par8.add(new Phrase(Chunk.NEWLINE)); par8.add(new Phrase(Chunk.NEWLINE)); documento.add(par8); PdfPTable tabla3 = new PdfPTable(8); FontFactory.registerDirectories(); PdfPCell celda80 = new PdfPCell(new Paragraph("Tipo de Riego", FontFactory.getFont("Times New Roman", 12, Font.BOLD, BaseColor.BLACK))); celda80.setHorizontalAlignment(Element.ALIGN_CENTER); PdfPCell celda90 = new PdfPCell(new Paragraph("Cantidad Alquiler", FontFactory.getFont("Times New Roman", 12, Font.BOLD, BaseColor.BLACK))); celda90.setHorizontalAlignment(Element.ALIGN_CENTER); PdfPCell celda100 = new PdfPCell(new Paragraph("Valor Alquiler", FontFactory.getFont("Times New Roman", 12, Font.BOLD, BaseColor.BLACK))); celda100.setHorizontalAlignment(Element.ALIGN_CENTER); PdfPCell celda110 = new PdfPCell(new Paragraph("Valor Total Alquiler", FontFactory.getFont("Times New Roman", 12, Font.BOLD, BaseColor.BLACK))); celda110.setHorizontalAlignment(Element.ALIGN_CENTER); PdfPCell celda120 = new PdfPCell(new Paragraph("Valor Tarifa Distrito", FontFactory.getFont("Times New Roman", 12, Font.BOLD, BaseColor.BLACK))); celda120.setHorizontalAlignment(Element.ALIGN_CENTER); PdfPCell celda130 = new PdfPCell(new Paragraph("Valor Tarifa Corponor", FontFactory.getFont("Times New Roman", 12, Font.BOLD, BaseColor.BLACK))); celda130.setHorizontalAlignment(Element.ALIGN_CENTER); PdfPCell celda140 = new PdfPCell(new Paragraph("Valor Total Tarifa", FontFactory.getFont("Times New Roman", 12, Font.BOLD, BaseColor.BLACK))); celda140.setHorizontalAlignment(Element.ALIGN_CENTER); PdfPCell celda150 = new PdfPCell(new Paragraph("Costo Total", FontFactory.getFont("Times New Roman", 12, Font.BOLD, BaseColor.BLACK))); celda150.setHorizontalAlignment(Element.ALIGN_CENTER); tabla3.addCell(celda80); tabla3.addCell(celda90); tabla3.addCell(celda100); tabla3.addCell(celda110); tabla3.addCell(celda120); tabla3.addCell(celda130); tabla3.addCell(celda140); tabla3.addCell(celda150); while (rs4.next()) { tabla3.addCell(rs4.getString("tipo_riego")); tabla3.addCell(rs4.getString("cantidad_alquiler_riego")); tabla3.addCell(rs4.getString("valor_alquiler_riego")); tabla3.addCell(rs4.getString("total_alquiler_riego")); tabla3.addCell(rs4.getString("valor_tarifa_districto_riego")); tabla3.addCell(rs4.getString("valor_tarifa_corponor_riego")); tabla3.addCell(rs4.getString("total_tarifa_riego")); tabla3.addCell(rs4.getString("valor_total_riego")); } documento.add(tabla3); } catch (Exception e) { e.printStackTrace(); } documento.close(); } } catch (Exception e) { e.getMessage(); } } finally { out.close(); } }