List of usage examples for com.itextpdf.text FontFactory getFont
public static Font getFont(final String fontname, final float size, final int style, final BaseColor color)
Font
-object. From source file:project1.GENERALCV.java
private void createcvActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_createcvActionPerformed String firstname, lastname, contactno, email, phonenumber, address; String dob, martialStatus, cast, careerObjectives; String university, city, startdatee, enddatee, coursesAndQualification; String acedemicQualification, certificates, experience, techskills, addSkills; String achivements, additionalCertificates, references, hobbies; firstname = txtname.getText();//from ww w .j a va 2 s. co m lastname = txtlastname.getText(); email = txtemail.getText(); phonenumber = txtMobileNo.getText(); address = txtAddress.getText(); SimpleDateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy"); String link = txtLink.getText(); // dob= dateFormat.format(dateOfBirth.getDate()); martialStatus = cmbMartialStatus.getSelectedItem().toString(); // cast=txtcast.getText(); // careerObjectives=txtcareer.getText(); university = txtCollegeName.getText(); city = txtCity.getText(); // startdatee=dateFormat.format(startdate.getDate()); // enddatee=dateFormat.format(enddate.getDate()); coursesAndQualification = txtExtraCourses.getText(); // certificates=txtcertificats.getText(); // experience=txtexperience.getText(); techskills = txttechnical.getText(); // addSkills=txtadditional.getText(); references = txtreference.getText(); try { Class.forName("com.mysql.jdbc.Driver"); con = DriverManager.getConnection("jdbc:mysql://localhost:3306/cvmaker", "root", "12345"); pInsertPerson = con .prepareStatement("INSERT INTO PERSONS(NAMEE,CONTACTNO,EMAILID,ADDRESS) VALUES(?,?,?,?)"); pInsertPerson.setString(1, firstname + lastname); pInsertPerson.setString(2, phonenumber); pInsertPerson.setString(3, email); pInsertPerson.setString(4, address); pInsertPerson.executeUpdate(); JOptionPane.showMessageDialog(null, "Data Is Alo Saved In Database...."); showRecords(); } catch (Exception e) { System.out.println(e.toString()); } Statement statement; String selectTableSQL = "SELECT ID FROM PERSONS"; int ss = 0; try { Class.forName("com.mysql.jdbc.Driver"); con = DriverManager.getConnection("jdbc:mysql://localhost:3306/cvmaker", "root", "12345"); statement = con.createStatement(); //System.out.println(selectTableSQL); // execute select SQL stetementS ResultSet rs = statement.executeQuery(selectTableSQL); while (rs.next()) { ss = rs.getInt("ID"); } } catch (SQLException e) { System.out.println(e.toString()); } catch (ClassNotFoundException ex) { Logger.getLogger(FRESHERCV.class.getName()).log(Level.SEVERE, null, ex); } int newcvid = ss; try { OutputStream file = new FileOutputStream(new File("D:\\PDFFILES\\" + firstname + lastname + ".pdf")); Document document = new Document(); PdfWriter.getInstance(document, file); document.open(); // Image im=Image.getInstance("E:\\PDFFILES\\FUUAST.png"); // document.add(new Paragraph("")); // document.add(im); Paragraph title1 = new Paragraph(firstname + " " + lastname + " Cv", FontFactory .getFont(FontFactory.HELVETICA, 36, Font.BOLDITALIC, new CMYKColor(0, 255, 255, 17))); Chapter chapter1 = new Chapter(title1, 1); chapter1.setNumberDepth(0); document.add(chapter1); document.add(new Paragraph("\n\n")); List unorderedList = new List(List.UNORDERED); unorderedList.add(new ListItem("Mobile No:" + phonenumber)); unorderedList.add(new ListItem("Email:" + city)); unorderedList.add(new ListItem("Address:" + address)); // unorderedList.add(new ListItem("End Date:" + enddatee)); document.add(unorderedList); // document.add(new Paragraph("Address:"+address)); Paragraph title2 = new Paragraph("Personal Information", FontFactory.getFont(FontFactory.HELVETICA, 24, Font.BOLDITALIC, new CMYKColor(0, 255, 255, 17))); title2.setAlignment(Element.ALIGN_CENTER); document.add(title2); // document.add(new Paragraph("Date Of Birth:" + dob)); document.add(new Paragraph("Martial Status:" + martialStatus)); // document.add(new Paragraph("Cast:"+cast)); // document.add(new Paragraph("Career Objectives:"+careerObjectives)); Paragraph title3 = new Paragraph("Qualification", FontFactory.getFont(FontFactory.HELVETICA, 24, Font.BOLDITALIC, new CMYKColor(0, 255, 255, 17))); title3.setAlignment(Element.ALIGN_CENTER); document.add(title3); PdfPTable table = new PdfPTable(2); // 3 columns. document.add(new Paragraph("\n\n")); PdfPCell cell1 = new PdfPCell(new Paragraph("Insituite Name:")); PdfPCell cell2 = new PdfPCell(new Paragraph(university)); PdfPCell cell3 = new PdfPCell(new Paragraph("City:")); PdfPCell cell4 = new PdfPCell(new Paragraph(city)); PdfPCell cell5 = new PdfPCell(new Paragraph("Start Date:")); // PdfPCell cell6 = new PdfPCell(new Paragraph(startdatee)); PdfPCell cell7 = new PdfPCell(new Paragraph("End Date:")); //PdfPCell cell8 = new PdfPCell(new Paragraph(enddatee)); PdfPCell cell71 = new PdfPCell(new Paragraph("Extra Courses:")); PdfPCell cell81 = new PdfPCell(new Paragraph(coursesAndQualification)); table.addCell(cell1); table.addCell(cell2); table.addCell(cell3); table.addCell(cell4); table.addCell(cell5); // table.addCell(cell6); table.addCell(cell7); // table.addCell(cell8); table.addCell(cell71); table.addCell(cell81); document.add(table); // document.add(new Paragraph("Extra Courses:"+coursesAndQualification)); // document.add(new Paragraph("Certificates:"+certificates)); // Paragraph title4 = new Paragraph("Experience", FontFactory.getFont(FontFactory.HELVETICA, 24, Font.BOLDITALIC, new CMYKColor(0, 255, 255, 17))); title4.setAlignment(Element.ALIGN_CENTER); document.add(title4); // document.add(new Paragraph(""+experience)); Paragraph title5 = new Paragraph("Skills", FontFactory.getFont(FontFactory.HELVETICA, 24, Font.BOLDITALIC, new CMYKColor(0, 255, 255, 17))); title5.setAlignment(Element.ALIGN_CENTER); document.add(title5); document.add(new Paragraph("Technical Skills:" + techskills)); // document.add(new Paragraph("Additional Skills:"+addSkills)); Paragraph title6 = new Paragraph("References", FontFactory.getFont(FontFactory.HELVETICA, 24, Font.BOLDITALIC, new CMYKColor(0, 255, 255, 17))); title6.setAlignment(Element.ALIGN_CENTER); document.add(title6); document.add(new Paragraph("References:" + references)); // Anchor anchor; // anchor = new Anchor(link, FontFactory.getFont(FontFactory.HELVETICA,12, Font.UNDERLINE, new CMYKColor(0, 0,0,255))); // anchor.setReference( link); Paragraph paragraph = new Paragraph("Profile Link:"); // paragraph.add(anchor); document.add(paragraph); Paragraph title11 = new Paragraph( " Cv Number:" + newcvid, FontFactory .getFont(FontFactory.HELVETICA, 15, Font.BOLDITALIC, new CMYKColor(0, 255, 255, 17))); document.add(new Paragraph("\n\n")); document.add(title11); try { Desktop desktop = Desktop.getDesktop(); if (desktop.isSupported(Desktop.Action.OPEN)) { desktop.open(new File("D:\\PDFFILES\\" + firstname + lastname + ".pdf")); } else { System.out.println("Open is not supported"); } } catch (IOException exp) { exp.printStackTrace(); } document.close(); file.close(); } catch (Exception e) { e.printStackTrace(); } }
From source file:project1.SimplePdf.java
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed // TODO add your handling code here: int id;//from w ww . j a v a2 s . co m String name; id = Integer.parseInt(txtid.getText()); name = txtname.getText(); try { OutputStream file = new FileOutputStream(new File("F:\\PDFFILES\\" + id + ".pdf")); Document document = new Document(); PdfWriter.getInstance(document, file); document.open(); // Image im=Image.getInstance("E:\\PDFFILES\\FUUAST.png"); // document.add(new Paragraph("")); // document.add(im); Paragraph title1 = new Paragraph(name + id, FontFactory.getFont(FontFactory.HELVETICA, 36, Font.BOLDITALIC, new CMYKColor(0, 255, 255, 17))); Chapter chapter1 = new Chapter(title1, 1); chapter1.setNumberDepth(0); document.add(chapter1); document.add(new Paragraph("\n\n\n\n")); document.add(new Paragraph("Name: " + name)); document.add(new Paragraph("Id: " + id)); try { Desktop desktop = Desktop.getDesktop(); if (desktop.isSupported(Desktop.Action.OPEN)) { desktop.open(new File("D:\\PDFFILES\\" + id + ".pdf")); } else { System.out.println("Open is not supported"); } } catch (IOException exp) { exp.printStackTrace(); } document.close(); file.close(); } catch (Exception e) { e.printStackTrace(); } }
From source file:proyectopdf.Pleno.java
public static void main(String a[]) throws FileNotFoundException, DocumentException, IOException { String ae;//from w w w .j a v a 2s .c o m JFileChooser jfc = new JFileChooser(); jfc.showOpenDialog(null); BufferedReader archivo = new BufferedReader(new FileReader(jfc.getSelectedFile().getPath())); FileOutputStream nuevo = new FileOutputStream("hola.pdf"); Document documento = new Document(); PdfWriter.getInstance(documento, nuevo); documento.open(); String w; while (archivo.ready()) { ae = archivo.readLine(); StringTokenizer tituloI = new StringTokenizer(ae, "{T}{#T}{C}{#C}{P}{#P}{S}{#S}"); while (tituloI.hasMoreTokens()) { String a1 = tituloI.nextToken(); w = a1; documento.add(new Paragraph(a1, FontFactory.getFont("arial", // fuente 22, // tamao Font.ITALIC, // estilo BaseColor.BLUE))); } String a2 = ""; while (tituloI.hasMoreTokens()) { a2 = tituloI.nextToken(); documento.add(new Paragraph(a2, FontFactory.getFont("arial", // fuente 22, // tamao Font.ITALIC, // estilo BaseColor.RED))); } String a3 = ""; while (tituloI.hasMoreTokens()) { a3 = tituloI.nextToken(); documento.add(new Paragraph(a3, FontFactory.getFont("arial", // fuente 22, // tamao Font.ITALIC, // estilo BaseColor.CYAN))); } String a4 = ""; while (tituloI.hasMoreTokens()) { a4 = tituloI.nextToken(); documento.add(new Paragraph(a4, FontFactory.getFont("arial", // fuente 22, // tamao Font.ITALIC, // estilo BaseColor.YELLOW))); } System.out.println(archivo.readLine()); } documento.close(); }
From source file:reporteFertilizacion.ReporteResultadoLaboratorio.java
/** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> * methods.//from w ww.java2 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("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:Reportes.ReportePersonal.java
public Paragraph crearTitulo(String titulo) { Paragraph parrafo2 = new Paragraph(titulo, FontFactory.getFont("arial", 18, Font.BOLD, BaseColor.BLACK)); // fuente, tamao, estilo, color parrafo2.setAlignment(1);//el 1 es para centrar return parrafo2; }
From source file:Reportes.ReportePersonal.java
public PdfPTable tablaTitulos() { PdfPTable tabla = null;//from w w w . j ava 2s.com int numeroColumnas; String V[] = new String[5]; V[0] = "Tipo Documento"; V[1] = "Documento"; V[2] = "Nombre"; V[3] = "Correo"; V[4] = "Perfil"; // ResultSetMetaData metaDatos = rs.getMetaData(); // Se obtiene el numero de columnas. numeroColumnas = 5;//metaDatos.getColumnCount(); tabla = new PdfPTable(numeroColumnas); PdfPCell celda = null; for (int i = 0; i < numeroColumnas; i++) { String tituloColumna = V[i]; celda = new PdfPCell( new Paragraph(tituloColumna, FontFactory.getFont("arial", 12, Font.BOLD, BaseColor.BLACK))); celda.setBackgroundColor(BaseColor.WHITE); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); } return tabla; }
From source file:Reportes.ReportePersonal.java
public PdfPTable tablaDatos() { PdfPTable tabla = null;/*from w ww .ja va 2s . c om*/ int numeroColumnas; String tipoDoc, documento, nombre, correo, perfil; String V[] = new String[6]; PdfPCell celda; // Se obtiene el numero de columnas. numeroColumnas = 5; tabla = new PdfPTable(numeroColumnas);//construye una tabla con el nmero de columnas requeridas while (Nodo != null) // recorre cada registro del resultset { tipoDoc = Nodo.getUsuario().getTipoDoc(); documento = Nodo.getUsuario().getDocumento(); nombre = Nodo.getUsuario().getNombre(); correo = Nodo.getUsuario().getCorreo(); perfil = Nodo.getUsuario().getPerfil(); V[0] = tipoDoc; V[1] = documento; V[2] = nombre; V[3] = correo; V[4] = perfil; for (int i = 0; i < numeroColumnas; i++)//lee cada campo del registro activo { String fila = V[i]; celda = new PdfPCell( new Paragraph(fila, FontFactory.getFont("arial", 12, Font.NORMAL, BaseColor.BLACK))); celda.setBackgroundColor(BaseColor.WHITE); tabla.addCell(celda); } Nodo = Nodo.getLiga(); } return tabla; }
From source file:se.wsu.lmw.Controls.Report.java
public void Create_report() { try {//w w w . j a va 2 s .c o m Document document = new Document(); PdfWriter.getInstance(document, new FileOutputStream("Booklist_Report.pdf")); document.open(); document.add(new Paragraph( "----------------------------------------Library-------------------------------------", FontFactory.getFont(FontFactory.TIMES_BOLD, 18, Font.BOLD, BaseColor.BLACK))); document.add(new Paragraph(new Date().toString())); document.add(new Paragraph( "----------------------------------------------------------------------------------------------------------------------------------")); document.add(new Paragraph("_________________________________________", FontFactory.getFont(FontFactory.TIMES_BOLD, 18, Font.BOLD, BaseColor.WHITE))); PdfPTable table = new PdfPTable(new float[] { 35, 45, 35, 45, 45, 45, 45, 45 }); table.addCell("Book ID"); table.addCell("Book name"); table.addCell("Total Qty"); table.addCell("Available Qty"); table.addCell("Librarian ID"); table.addCell("Rack ID"); table.addCell("Category ID"); table.addCell("Publisher ID"); ResultSet result = new GetBookDetails().getBook(); while (result.next()) { table.addCell(result.getString(1)); table.addCell(result.getString(2)); table.addCell(result.getString(3)); table.addCell(result.getString(4)); table.addCell(result.getString(5)); table.addCell(result.getString(6)); table.addCell(result.getString(7)); table.addCell(result.getString(9)); } document.add(table); document.add(new Paragraph("_________________________________________", FontFactory.getFont(FontFactory.TIMES_BOLD, 18, Font.BOLD, BaseColor.WHITE))); document.add(new Paragraph("_________________________________________", FontFactory.getFont(FontFactory.TIMES_BOLD, 18, Font.BOLD, BaseColor.WHITE))); document.close(); Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + "Booklist_Report.pdf"); } catch (Exception e) { System.out.println(e); JOptionPane.showMessageDialog(null, "report not created", "Error", 3); } }
From source file:se.wsu.lmw.Controls.Report.java
public void Create_report2() { try {/* w ww .j a v a 2s.c o m*/ Document document = new Document(); PdfWriter.getInstance(document, new FileOutputStream("Borrowed_Booklist.pdf")); document.open(); document.add(new Paragraph( "----------------------------------------Library-------------------------------------", FontFactory.getFont(FontFactory.TIMES_BOLD, 18, Font.BOLD, BaseColor.BLACK))); document.add(new Paragraph(new Date().toString())); document.add(new Paragraph( "----------------------------------------------------------------------------------------------------------------------------------")); document.add(new Paragraph("_________________________________________", FontFactory.getFont(FontFactory.TIMES_BOLD, 18, Font.BOLD, BaseColor.WHITE))); PdfPTable table = new PdfPTable(6); table.addCell("Member ID"); table.addCell("Book ID"); table.addCell("Librarian ID"); table.addCell("Borrowed date"); table.addCell("Returned date"); table.addCell("Borrowed ID"); ResultSet result = new GetBookDetails().getBorrowed(); while (result.next()) { table.addCell(result.getString(1)); table.addCell(result.getString(2)); table.addCell(result.getString(3)); table.addCell(result.getString(4)); table.addCell(result.getString(5)); table.addCell(result.getString(6)); } document.add(table); document.add(new Paragraph("_________________________________________", FontFactory.getFont(FontFactory.TIMES_BOLD, 18, Font.BOLD, BaseColor.WHITE))); document.add(new Paragraph("_________________________________________", FontFactory.getFont(FontFactory.TIMES_BOLD, 18, Font.BOLD, BaseColor.WHITE))); document.close(); Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + "Borrowed_Booklist.pdf"); } catch (Exception e) { System.out.println(e); JOptionPane.showMessageDialog(null, "report not created", "Error", 3); } }
From source file:servlet.SalesReportPDF.java
/** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> * methods.//from w w w . ja va 2 s .c om * * @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); } }