List of usage examples for com.itextpdf.text PageSize LETTER
Rectangle LETTER
To view the source code for com.itextpdf.text PageSize LETTER.
Click Source Link
From source file:managedbeans.Doctor.ImprimirAnamnesis.java
/** * Handles the HTTP <code>GET</code> method. * * @param request servlet request//from w w w . ja va2s . co m * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ @Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("application/pdf"); String rut = request.getParameter("rut"); String id = request.getParameter("id"); Integer search = Integer.parseInt(rut); Integer idEp = Integer.parseInt(id); episodio = episodiosFacade.find(idEp); List<Persona> person = personaNegocio.busquedaPersonaRut(search); Persona personSelected; if (person.size() > 0) { System.out.println("La cantidad es:" + person.size()); personSelected = person.get(0); System.out.println("La cantidad es:" + personSelected.getPersNombres()); paciente = pacienteNegocio.busquedaPacienteIdPersona(personSelected.getIdPersona()); signos = muestaFacade.searchByPatient(paciente); if (signos.size() > 0) { for (Muesta signo : signos) { if (signo.getIdSvitales().getIdSvitales() == 1) peso = signo.getValor(); if (signo.getIdSvitales().getIdSvitales() == 2) altura = signo.getValor(); if (signo.getIdSvitales().getIdSvitales() == 3) temperatura = signo.getValor(); if (signo.getIdSvitales().getIdSvitales() == 5) presion = signo.getValor(); if (signo.getIdSvitales().getIdSvitales() == 9) pulso = signo.getValor(); if (signo.getIdSvitales().getIdSvitales() == 17) imc = signo.getValor(); } } if (consultaFacade.searchByEpisodio(episodio).size() > 0) consulta = consultaFacade.searchByEpisodio(episodio).get(0); patientName = personSelected.getPersNombres() + " " + personSelected.getPersApepaterno() + " " + personSelected.getPersApematerno(); patientRut = search; patientFonasa = ""; patientIsapre = paciente.getPaciOtraprevision(); home = personSelected.getPersDireccion(); commune = paciente.getPersona().getIdComuna().getComuNombre(); region = ""; phoneNumber = personSelected.getPersTelefono(); celularNumber = personSelected.getPersCelular(); mail = personSelected.getPersEmail(); } try { //style Font typeBold = new Font(Font.FontFamily.TIMES_ROMAN, 12, 1); Font type = new Font(Font.FontFamily.TIMES_ROMAN, 10); Font title = new Font(Font.FontFamily.TIMES_ROMAN, 15, 1); Font subTitle = new Font(Font.FontFamily.TIMES_ROMAN, 13, 1); Font subTitle2 = new Font(Font.FontFamily.TIMES_ROMAN, 10, 1); float space = (float) 20; Document document = new Document(); document.setPageSize(PageSize.LETTER); PdfWriter.getInstance(document, response.getOutputStream()); document.open(); //General PdfPTable table; Paragraph p1; Paragraph p2; PdfPCell cellRow1; PdfPCell cellRow2; //row: 1 table = new PdfPTable(2); table.setWidthPercentage(100); p1 = new Paragraph(space, "ANAMNESIS", title); p1.setAlignment(Element.ALIGN_CENTER); cellRow1 = new PdfPCell(p1); cellRow1.setColspan(2); formatCellBorder(cellRow1, 20); table.addCell(cellRow1); p1 = new Paragraph(space, "Hospital Barros Luco", subTitle2); p1.setAlignment(Element.ALIGN_CENTER); cellRow1 = new PdfPCell(p1); cellRow1.setColspan(2); formatCellBorder(cellRow1, 20); table.addCell(cellRow1); document.add(table); document.add(new Paragraph("\n")); //row 3 table = new PdfPTable(2); table.setWidthPercentage(100); p1 = new Paragraph(space, "ANTECEDENTES DEL PACIENTE", subTitle); cellRow1 = new PdfPCell(p1); cellRow1.setColspan(2); formatCellBorder(cellRow1, 20); cellRow1.setBorderWidthTop(1); cellRow1.setBorderWidthLeft(1); cellRow1.setBorderWidthRight(1); cellRow1.setBorderWidthBottom(1); table.addCell(cellRow1); p1 = new Paragraph(space, "NOMBRE: " + patientName, type); cellRow1 = new PdfPCell(p1); cellRow1.setColspan(2); formatCellBorder(cellRow1, 20); cellRow1.setBorderWidthLeft(1); cellRow1.setBorderWidthRight(1); table.addCell(cellRow1); p1 = new Paragraph(space, "RUT: " + patientRut, type); p2 = new Paragraph(space, "PREVISION: " + paciente.getIdPrevision().getPreviNombre(), type); cellRow1 = new PdfPCell(p1); cellRow2 = new PdfPCell(p2); formatCellBorder(cellRow1, 20); formatCellBorder(cellRow2, 20); cellRow1.setBorderWidthLeft(1); cellRow2.setBorderWidthRight(1); table.addCell(cellRow1); table.addCell(cellRow2); p1 = new Paragraph(space, "COMUNA: " + commune, type); p2 = new Paragraph(space, "DOMICILIO: " + home, type); cellRow1 = new PdfPCell(p1); cellRow2 = new PdfPCell(p2); formatCellBorder(cellRow1, 20); formatCellBorder(cellRow2, 20); cellRow1.setBorderWidthLeft(1); cellRow2.setBorderWidthRight(1); table.addCell(cellRow1); table.addCell(cellRow2); p1 = new Paragraph(space, "TELFONO DE CONTACTO: " + paciente.getPersona().getPersTelcontacto(), type); p2 = new Paragraph(space, "CORREO: " + paciente.getPersona().getPersEmail(), type); cellRow1 = new PdfPCell(p1); cellRow2 = new PdfPCell(p2); formatCellBorder(cellRow1, 20); formatCellBorder(cellRow2, 20); cellRow1.setBorderWidthLeft(1); cellRow2.setBorderWidthRight(1); cellRow1.setBorderWidthBottom(1); cellRow2.setBorderWidthBottom(1); table.addCell(cellRow1); table.addCell(cellRow2); document.add(table); document.add(new Paragraph("\n")); //row 4 table = new PdfPTable(2); table.setWidthPercentage(100); p1 = new Paragraph(space, "ANAMNESIS", subTitle); cellRow1 = new PdfPCell(p1); cellRow1.setColspan(2); formatCellBorder(cellRow1, 20); cellRow1.setBorderWidthTop(1); cellRow1.setBorderWidthLeft(1); cellRow1.setBorderWidthRight(1); cellRow1.setBorderWidthBottom(1); table.addCell(cellRow1); p1 = new Paragraph(space, consulta.getMotivoConsulta(), type); cellRow1 = new PdfPCell(p1); cellRow1.setColspan(2); formatCellBorder(cellRow1, 20); cellRow1.setBorderWidthLeft(1); cellRow1.setBorderWidthRight(1); cellRow1.setBorderWidthBottom(1); table.addCell(cellRow1); document.add(table); document.add(new Paragraph("\n")); table = new PdfPTable(2); table.setWidthPercentage(100); p1 = new Paragraph(space, "HISTORIA OBSTTRICA", subTitle); cellRow1 = new PdfPCell(p1); cellRow1.setColspan(2); formatCellBorder(cellRow1, 20); cellRow1.setBorderWidthTop(1); cellRow1.setBorderWidthLeft(1); cellRow1.setBorderWidthRight(1); cellRow1.setBorderWidthBottom(1); table.addCell(cellRow1); p1 = new Paragraph(space, "F.U.R.: ", type); p2 = new Paragraph(space, "F.P.P.: ", type); cellRow1 = new PdfPCell(p1); cellRow2 = new PdfPCell(p2); formatCellBorder(cellRow1, 20); formatCellBorder(cellRow2, 20); cellRow1.setBorderWidthLeft(1); cellRow2.setBorderWidthRight(1); table.addCell(cellRow1); table.addCell(cellRow2); p1 = new Paragraph(space, "PARTOS: ", type); p2 = new Paragraph(space, "ABORTOS: ", type); cellRow1 = new PdfPCell(p1); cellRow2 = new PdfPCell(p2); formatCellBorder(cellRow1, 20); formatCellBorder(cellRow2, 20); cellRow1.setBorderWidthLeft(1); cellRow2.setBorderWidthRight(1); table.addCell(cellRow1); table.addCell(cellRow2); p1 = new Paragraph(space, "FECHA LTIMO PARTO: ", type); cellRow1 = new PdfPCell(p1); cellRow1.setColspan(2); formatCellBorder(cellRow1, 20); cellRow1.setBorderWidthLeft(1); cellRow1.setBorderWidthRight(1); cellRow1.setBorderWidthBottom(1); table.addCell(cellRow1); document.add(table); document.add(new Paragraph("\n")); table = new PdfPTable(2); table.setWidthPercentage(100); p1 = new Paragraph(space, "EX?MEN F?SICO", subTitle); cellRow1 = new PdfPCell(p1); cellRow1.setColspan(2); formatCellBorder(cellRow1, 20); cellRow1.setBorderWidthTop(1); cellRow1.setBorderWidthLeft(1); cellRow1.setBorderWidthRight(1); cellRow1.setBorderWidthBottom(1); table.addCell(cellRow1); p1 = new Paragraph(space, "PRESIN ARTERIAL: " + presion, type); p2 = new Paragraph(space, "TEMPERATURA: " + temperatura, type); cellRow1 = new PdfPCell(p1); cellRow2 = new PdfPCell(p2); formatCellBorder(cellRow1, 20); formatCellBorder(cellRow2, 20); cellRow1.setBorderWidthLeft(1); cellRow2.setBorderWidthRight(1); table.addCell(cellRow1); table.addCell(cellRow2); p1 = new Paragraph(space, "PULSO: " + pulso, type); p2 = new Paragraph(space, "PESO: " + peso, type); cellRow1 = new PdfPCell(p1); cellRow2 = new PdfPCell(p2); formatCellBorder(cellRow1, 20); formatCellBorder(cellRow2, 20); cellRow1.setBorderWidthLeft(1); cellRow2.setBorderWidthRight(1); table.addCell(cellRow1); table.addCell(cellRow2); p1 = new Paragraph(space, "TALLA: " + altura, type); p2 = new Paragraph(space, "I.M.C.: " + imc, type); cellRow1 = new PdfPCell(p1); cellRow2 = new PdfPCell(p2); formatCellBorder(cellRow1, 20); formatCellBorder(cellRow2, 20); cellRow1.setBorderWidthLeft(1); cellRow2.setBorderWidthRight(1); cellRow1.setBorderWidthBottom(1); cellRow2.setBorderWidthBottom(1); table.addCell(cellRow1); table.addCell(cellRow2); document.add(table); document.add(new Paragraph("\n")); table = new PdfPTable(2); table.setWidthPercentage(100); p1 = new Paragraph(space, "EX?MEN OBSTTRICO", subTitle); cellRow1 = new PdfPCell(p1); cellRow1.setColspan(2); formatCellBorder(cellRow1, 20); cellRow1.setBorderWidthTop(1); cellRow1.setBorderWidthLeft(1); cellRow1.setBorderWidthRight(1); cellRow1.setBorderWidthBottom(1); table.addCell(cellRow1); p1 = new Paragraph(space, "A.U.: ", type); p2 = new Paragraph(space, "L.C.F.: ", type); cellRow1 = new PdfPCell(p1); cellRow2 = new PdfPCell(p2); formatCellBorder(cellRow1, 20); formatCellBorder(cellRow2, 20); cellRow1.setBorderWidthLeft(1); cellRow2.setBorderWidthRight(1); table.addCell(cellRow1); table.addCell(cellRow2); p1 = new Paragraph(space, "D.U.: ", type); p2 = new Paragraph(space, "PRESENTACIN: ", type); cellRow1 = new PdfPCell(p1); cellRow2 = new PdfPCell(p2); formatCellBorder(cellRow1, 20); formatCellBorder(cellRow2, 20); cellRow1.setBorderWidthLeft(1); cellRow2.setBorderWidthRight(1); if (1 == 0) { table.addCell(cellRow1); table.addCell(cellRow2); p1 = new Paragraph(space, "POSICIN: ", type); p2 = new Paragraph(space, "CONSISTENCIA: ", type); cellRow1 = new PdfPCell(p1); cellRow2 = new PdfPCell(p2); formatCellBorder(cellRow1, 20); formatCellBorder(cellRow2, 20); cellRow1.setBorderWidthLeft(1); cellRow2.setBorderWidthRight(1); table.addCell(cellRow1); table.addCell(cellRow2); p1 = new Paragraph(space, "BORRAMIENTO: ", type); p2 = new Paragraph(space, "DILATACION: ", type); cellRow1 = new PdfPCell(p1); cellRow2 = new PdfPCell(p2); formatCellBorder(cellRow1, 20); formatCellBorder(cellRow2, 20); cellRow1.setBorderWidthLeft(1); cellRow2.setBorderWidthRight(1); table.addCell(cellRow1); table.addCell(cellRow2); p1 = new Paragraph(space, "PLANO: ", type); p2 = new Paragraph(space, "MEMBRANAS: ", type); cellRow1 = new PdfPCell(p1); cellRow2 = new PdfPCell(p2); formatCellBorder(cellRow1, 20); formatCellBorder(cellRow2, 20); cellRow1.setBorderWidthLeft(1); cellRow2.setBorderWidthRight(1); } cellRow1.setBorderWidthBottom(1); cellRow2.setBorderWidthBottom(1); table.addCell(cellRow1); table.addCell(cellRow2); document.add(table); document.add(new Paragraph("\n")); table = new PdfPTable(2); table.setWidthPercentage(100); p1 = new Paragraph(space, "RESUMEN PATOLOG?AS MATERNAS", subTitle); cellRow1 = new PdfPCell(p1); cellRow1.setColspan(2); formatCellBorder(cellRow1, 20); cellRow1.setBorderWidthTop(1); cellRow1.setBorderWidthLeft(1); cellRow1.setBorderWidthRight(1); cellRow1.setBorderWidthBottom(1); table.addCell(cellRow1); p1 = new Paragraph(space, "PATOLOG?AS: ", type); cellRow1 = new PdfPCell(p1); cellRow1.setColspan(2); formatCellBorder(cellRow1, 20); cellRow1.setBorderWidthLeft(1); cellRow1.setBorderWidthRight(1); cellRow1.setBorderWidthBottom(1); table.addCell(cellRow1); document.add(table); document.add(new Paragraph("\n")); table = new PdfPTable(2); table.setWidthPercentage(100); p1 = new Paragraph(space, "DIAGNOSTICOS", subTitle); cellRow1 = new PdfPCell(p1); cellRow1.setColspan(2); formatCellBorder(cellRow1, 20); cellRow1.setBorderWidthTop(1); cellRow1.setBorderWidthLeft(1); cellRow1.setBorderWidthRight(1); cellRow1.setBorderWidthBottom(1); table.addCell(cellRow1); p1 = new Paragraph(space, "Este es un diagnostico", type); cellRow1 = new PdfPCell(p1); cellRow1.setColspan(2); formatCellBorder(cellRow1, 20); cellRow1.setBorderWidthLeft(1); cellRow1.setBorderWidthRight(1); cellRow1.setBorderWidthBottom(1); table.addCell(cellRow1); document.add(table); document.add(new Paragraph("\n")); table = new PdfPTable(2); table.setWidthPercentage(100); p1 = new Paragraph(space, "INDICACIONES", subTitle); cellRow1 = new PdfPCell(p1); cellRow1.setColspan(2); formatCellBorder(cellRow1, 20); cellRow1.setBorderWidthTop(1); cellRow1.setBorderWidthLeft(1); cellRow1.setBorderWidthRight(1); cellRow1.setBorderWidthBottom(1); table.addCell(cellRow1); p1 = new Paragraph(space, "Estas son indicaciones", type); cellRow1 = new PdfPCell(p1); cellRow1.setColspan(2); formatCellBorder(cellRow1, 20); cellRow1.setBorderWidthLeft(1); cellRow1.setBorderWidthRight(1); cellRow1.setBorderWidthBottom(1); table.addCell(cellRow1); document.add(table); document.close(); } catch (DocumentException de) { throw new IOException(de.getMessage()); } }
From source file:managedbeans.ImprimirAnamnesis.java
/** * Handles the HTTP <code>GET</code> method. * * @param request servlet request/*from ww w.j a v a 2s. c om*/ * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ @Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("application/pdf"); String rut = request.getParameter("rut"); String idAnam = request.getParameter("id"); Integer search = Integer.parseInt(rut); Integer anam = Integer.parseInt(idAnam); anamnesis = anamnesisFacade.find(anam); List<Persona> person = personaNegocio.busquedaPersonaRut(search); Persona personSelected; if (person.size() > 0) { System.out.println("La cantidad es:" + person.size()); personSelected = person.get(0); System.out.println("La cantidad es:" + personSelected.getPersNombres()); paciente = pacienteNegocio.busquedaPacienteIdPersona(personSelected.getIdPersona()); patientName = personSelected.getPersNombres() + " " + personSelected.getPersApepaterno() + " " + personSelected.getPersApematerno(); patientRut = search; patientFonasa = ""; patientIsapre = paciente.getPaciOtraprevision(); home = personSelected.getPersDireccion(); commune = ""; region = ""; phoneNumber = personSelected.getPersTelefono(); celularNumber = personSelected.getPersCelular(); mail = personSelected.getPersEmail(); } try { //style Font typeBold = new Font(Font.FontFamily.TIMES_ROMAN, 12, 1); Font type = new Font(Font.FontFamily.TIMES_ROMAN, 10); Font title = new Font(Font.FontFamily.TIMES_ROMAN, 15, 1); Font subTitle = new Font(Font.FontFamily.TIMES_ROMAN, 13, 1); Font subTitle2 = new Font(Font.FontFamily.TIMES_ROMAN, 10, 1); float space = (float) 20; Document document = new Document(); document.setPageSize(PageSize.LETTER); PdfWriter.getInstance(document, response.getOutputStream()); document.open(); //General PdfPTable table; Paragraph p1; Paragraph p2; PdfPCell cellRow1; PdfPCell cellRow2; //row: 1 table = new PdfPTable(2); table.setWidthPercentage(100); p1 = new Paragraph(space, "ANAMNESIS", title); p1.setAlignment(Element.ALIGN_CENTER); cellRow1 = new PdfPCell(p1); cellRow1.setColspan(2); formatCellBorder(cellRow1, 20); table.addCell(cellRow1); p1 = new Paragraph(space, "Hospital Barros Luco", subTitle2); p1.setAlignment(Element.ALIGN_CENTER); cellRow1 = new PdfPCell(p1); cellRow1.setColspan(2); formatCellBorder(cellRow1, 20); table.addCell(cellRow1); document.add(table); document.add(new Paragraph("\n")); //row 3 table = new PdfPTable(2); table.setWidthPercentage(100); p1 = new Paragraph(space, "ANTECEDENTES DEL PACIENTE", subTitle); cellRow1 = new PdfPCell(p1); cellRow1.setColspan(2); formatCellBorder(cellRow1, 20); cellRow1.setBorderWidthTop(1); cellRow1.setBorderWidthLeft(1); cellRow1.setBorderWidthRight(1); cellRow1.setBorderWidthBottom(1); table.addCell(cellRow1); p1 = new Paragraph(space, "NOMBRE: " + patientName, type); cellRow1 = new PdfPCell(p1); cellRow1.setColspan(2); formatCellBorder(cellRow1, 20); cellRow1.setBorderWidthLeft(1); cellRow1.setBorderWidthRight(1); table.addCell(cellRow1); p1 = new Paragraph(space, "RUT: " + patientRut, type); p2 = new Paragraph(space, "FONASA: " + patientFonasa, type); cellRow1 = new PdfPCell(p1); cellRow2 = new PdfPCell(p2); formatCellBorder(cellRow1, 20); formatCellBorder(cellRow2, 20); cellRow1.setBorderWidthLeft(1); cellRow2.setBorderWidthRight(1); table.addCell(cellRow1); table.addCell(cellRow2); p1 = new Paragraph(space, "ISAPRE: " + patientIsapre, type); p2 = new Paragraph(space, "DOMICILIO: " + home, type); cellRow1 = new PdfPCell(p1); cellRow2 = new PdfPCell(p2); formatCellBorder(cellRow1, 20); formatCellBorder(cellRow2, 20); cellRow1.setBorderWidthLeft(1); cellRow2.setBorderWidthRight(1); table.addCell(cellRow1); table.addCell(cellRow2); p1 = new Paragraph(space, "COMUNA: " + commune, type); p2 = new Paragraph(space, "REGION: " + region, type); cellRow1 = new PdfPCell(p1); cellRow2 = new PdfPCell(p2); formatCellBorder(cellRow1, 20); formatCellBorder(cellRow2, 20); cellRow1.setBorderWidthLeft(1); cellRow2.setBorderWidthRight(1); table.addCell(cellRow1); table.addCell(cellRow2); p1 = new Paragraph(space, "N TELFONO FIJO: " + phoneNumber, type); p2 = new Paragraph(space, "N TELFONO CELULAR: " + celularNumber, type); cellRow1 = new PdfPCell(p1); cellRow2 = new PdfPCell(p2); formatCellBorder(cellRow1, 20); formatCellBorder(cellRow2, 20); cellRow1.setBorderWidthLeft(1); cellRow2.setBorderWidthRight(1); table.addCell(cellRow1); table.addCell(cellRow2); p1 = new Paragraph(space, "DIRECCIN CORREO ELECTRNICO (E-MAIL): " + mail, type); cellRow1 = new PdfPCell(p1); cellRow1.setColspan(2); formatCellBorder(cellRow1, 20); cellRow1.setBorderWidthLeft(1); cellRow1.setBorderWidthRight(1); cellRow1.setBorderWidthBottom(1); table.addCell(cellRow1); document.add(table); document.add(new Paragraph("\n")); //row 4 table = new PdfPTable(2); table.setWidthPercentage(100); p1 = new Paragraph(space, "ANAMNESIS", subTitle); cellRow1 = new PdfPCell(p1); cellRow1.setColspan(2); formatCellBorder(cellRow1, 20); cellRow1.setBorderWidthTop(1); cellRow1.setBorderWidthLeft(1); cellRow1.setBorderWidthRight(1); cellRow1.setBorderWidthBottom(1); table.addCell(cellRow1); p1 = new Paragraph(space, anamnesis.getAnamDescripcion(), type); cellRow1 = new PdfPCell(p1); cellRow1.setColspan(2); formatCellBorder(cellRow1, 20); cellRow1.setBorderWidthLeft(1); cellRow1.setBorderWidthRight(1); cellRow1.setBorderWidthBottom(1); table.addCell(cellRow1); document.add(table); document.add(new Paragraph("\n")); table = new PdfPTable(2); table.setWidthPercentage(100); p1 = new Paragraph(space, "HISTORIA OBSTTRICA", subTitle); cellRow1 = new PdfPCell(p1); cellRow1.setColspan(2); formatCellBorder(cellRow1, 20); cellRow1.setBorderWidthTop(1); cellRow1.setBorderWidthLeft(1); cellRow1.setBorderWidthRight(1); cellRow1.setBorderWidthBottom(1); table.addCell(cellRow1); p1 = new Paragraph(space, anamnesis.getAnamDescripcion(), type); cellRow1 = new PdfPCell(p1); cellRow1.setColspan(2); formatCellBorder(cellRow1, 20); cellRow1.setBorderWidthLeft(1); cellRow1.setBorderWidthRight(1); cellRow1.setBorderWidthBottom(1); table.addCell(cellRow1); document.add(table); document.add(new Paragraph("\n")); table = new PdfPTable(2); table.setWidthPercentage(100); p1 = new Paragraph(space, "EX?MEN F?SICO", subTitle); cellRow1 = new PdfPCell(p1); cellRow1.setColspan(2); formatCellBorder(cellRow1, 20); cellRow1.setBorderWidthTop(1); cellRow1.setBorderWidthLeft(1); cellRow1.setBorderWidthRight(1); cellRow1.setBorderWidthBottom(1); table.addCell(cellRow1); p1 = new Paragraph(space, anamnesis.getAnamDescripcion(), type); cellRow1 = new PdfPCell(p1); cellRow1.setColspan(2); formatCellBorder(cellRow1, 20); cellRow1.setBorderWidthLeft(1); cellRow1.setBorderWidthRight(1); cellRow1.setBorderWidthBottom(1); table.addCell(cellRow1); document.add(table); document.add(new Paragraph("\n")); table = new PdfPTable(2); table.setWidthPercentage(100); p1 = new Paragraph(space, "EX?MEN OBSTTRICO", subTitle); cellRow1 = new PdfPCell(p1); cellRow1.setColspan(2); formatCellBorder(cellRow1, 20); cellRow1.setBorderWidthTop(1); cellRow1.setBorderWidthLeft(1); cellRow1.setBorderWidthRight(1); cellRow1.setBorderWidthBottom(1); table.addCell(cellRow1); p1 = new Paragraph(space, anamnesis.getAnamDescripcion(), type); cellRow1 = new PdfPCell(p1); cellRow1.setColspan(2); formatCellBorder(cellRow1, 20); cellRow1.setBorderWidthLeft(1); cellRow1.setBorderWidthRight(1); cellRow1.setBorderWidthBottom(1); table.addCell(cellRow1); document.add(table); document.add(new Paragraph("\n")); table = new PdfPTable(2); table.setWidthPercentage(100); p1 = new Paragraph(space, "RESUMEN PATOLOG?AS MATERNAS", subTitle); cellRow1 = new PdfPCell(p1); cellRow1.setColspan(2); formatCellBorder(cellRow1, 20); cellRow1.setBorderWidthTop(1); cellRow1.setBorderWidthLeft(1); cellRow1.setBorderWidthRight(1); cellRow1.setBorderWidthBottom(1); table.addCell(cellRow1); p1 = new Paragraph(space, anamnesis.getAnamDescripcion(), type); cellRow1 = new PdfPCell(p1); cellRow1.setColspan(2); formatCellBorder(cellRow1, 20); cellRow1.setBorderWidthLeft(1); cellRow1.setBorderWidthRight(1); cellRow1.setBorderWidthBottom(1); table.addCell(cellRow1); document.add(table); document.add(new Paragraph("\n")); table = new PdfPTable(2); table.setWidthPercentage(100); p1 = new Paragraph(space, "DIAGNOSTICOS", subTitle); cellRow1 = new PdfPCell(p1); cellRow1.setColspan(2); formatCellBorder(cellRow1, 20); cellRow1.setBorderWidthTop(1); cellRow1.setBorderWidthLeft(1); cellRow1.setBorderWidthRight(1); cellRow1.setBorderWidthBottom(1); table.addCell(cellRow1); p1 = new Paragraph(space, anamnesis.getAnamDescripcion(), type); cellRow1 = new PdfPCell(p1); cellRow1.setColspan(2); formatCellBorder(cellRow1, 20); cellRow1.setBorderWidthLeft(1); cellRow1.setBorderWidthRight(1); cellRow1.setBorderWidthBottom(1); table.addCell(cellRow1); document.add(table); document.add(new Paragraph("\n")); table = new PdfPTable(2); table.setWidthPercentage(100); p1 = new Paragraph(space, "INDICACIONES", subTitle); cellRow1 = new PdfPCell(p1); cellRow1.setColspan(2); formatCellBorder(cellRow1, 20); cellRow1.setBorderWidthTop(1); cellRow1.setBorderWidthLeft(1); cellRow1.setBorderWidthRight(1); cellRow1.setBorderWidthBottom(1); table.addCell(cellRow1); p1 = new Paragraph(space, anamnesis.getAnamDescripcion(), type); cellRow1 = new PdfPCell(p1); cellRow1.setColspan(2); formatCellBorder(cellRow1, 20); cellRow1.setBorderWidthLeft(1); cellRow1.setBorderWidthRight(1); cellRow1.setBorderWidthBottom(1); table.addCell(cellRow1); document.add(table); document.close(); } catch (DocumentException de) { throw new IOException(de.getMessage()); } }
From source file:managedbeanTest.PruebaMartolo.java
@Override public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("application/pdf"); try {/* w w w . jav a 2 s . c o m*/ //style Font typeBold = new Font(Font.FontFamily.TIMES_ROMAN, 12, 1); Font type = new Font(Font.FontFamily.TIMES_ROMAN, 10); Font title = new Font(Font.FontFamily.TIMES_ROMAN, 15, 1); Font subTitle = new Font(Font.FontFamily.TIMES_ROMAN, 13, 1); Font subTitle2 = new Font(Font.FontFamily.TIMES_ROMAN, 10, 1); float space = (float) 20; Document document = new Document(); document.setPageSize(PageSize.LETTER); PdfWriter.getInstance(document, response.getOutputStream()); document.open(); //General PdfPTable table; Paragraph p1; Paragraph p2; PdfPCell cellRow1; PdfPCell cellRow2; //row: 1 table = new PdfPTable(2); table.setWidthPercentage(100); p1 = new Paragraph(space, "FORMULARIO DE CONSTANCIA DE INFORMACION AL PACIENTE GES", title); p1.setAlignment(Element.ALIGN_CENTER); cellRow1 = new PdfPCell(p1); cellRow1.setColspan(2); formatCellBorder(cellRow1, 20); table.addCell(cellRow1); p1 = new Paragraph(space, "(Artculo 24, Ley 19.966)", subTitle2); p1.setAlignment(Element.ALIGN_CENTER); cellRow1 = new PdfPCell(p1); cellRow1.setColspan(2); formatCellBorder(cellRow1, 20); table.addCell(cellRow1); document.add(table); document.add(new Paragraph("\n")); //row: 2 table = new PdfPTable(2); table.setWidthPercentage(100); p1 = new Paragraph(space, "DATOS DEL PRESTADOR", subTitle); cellRow1 = new PdfPCell(p1); cellRow1.setColspan(2); formatCellBorder(cellRow1, 20); cellRow1.setBorderWidthTop(1); cellRow1.setBorderWidthLeft(1); cellRow1.setBorderWidthRight(1); cellRow1.setBorderWidthBottom(1); table.addCell(cellRow1); p1 = new Paragraph(space, "INSTITUCIN (Hospital, Clnica, Consultorio,etc): " + institution, type); cellRow1 = new PdfPCell(p1); cellRow1.setColspan(2); formatCellBorder(cellRow1, 20); cellRow1.setBorderWidthLeft(1); cellRow1.setBorderWidthRight(1); table.addCell(cellRow1); p1 = new Paragraph(space, "DIRECCION: " + address, type); p2 = new Paragraph(space, "CIUDAD: " + city, type); cellRow1 = new PdfPCell(p1); cellRow2 = new PdfPCell(p2); formatCellBorder(cellRow1, 20); formatCellBorder(cellRow2, 20); cellRow1.setBorderWidthLeft(1); cellRow2.setBorderWidthRight(1); table.addCell(cellRow1); table.addCell(cellRow2); p1 = new Paragraph(space, "NOMBRE PERSONA QUE NOTIFICA: " + personName, type); p2 = new Paragraph(space, "RUT: " + rut, type); cellRow1 = new PdfPCell(p1); cellRow2 = new PdfPCell(p2); formatCellBorder(cellRow1, 20); formatCellBorder(cellRow2, 20); cellRow1.setBorderWidthLeft(1); cellRow2.setBorderWidthRight(1); cellRow1.setBorderWidthBottom(1); cellRow2.setBorderWidthBottom(1); table.addCell(cellRow1); table.addCell(cellRow2); document.add(table); document.add(new Paragraph("\n")); //row 3 table = new PdfPTable(2); table.setWidthPercentage(100); p1 = new Paragraph(space, "ANTECEDENTES DEL PACIENTE", subTitle); cellRow1 = new PdfPCell(p1); cellRow1.setColspan(2); formatCellBorder(cellRow1, 20); cellRow1.setBorderWidthTop(1); cellRow1.setBorderWidthLeft(1); cellRow1.setBorderWidthRight(1); cellRow1.setBorderWidthBottom(1); table.addCell(cellRow1); p1 = new Paragraph(space, "NOMBRE: " + patientName, type); cellRow1 = new PdfPCell(p1); cellRow1.setColspan(2); formatCellBorder(cellRow1, 20); cellRow1.setBorderWidthLeft(1); cellRow1.setBorderWidthRight(1); table.addCell(cellRow1); p1 = new Paragraph(space, "RUT: " + patientRut, type); p2 = new Paragraph(space, "FONASA: " + patientFonasa, type); cellRow1 = new PdfPCell(p1); cellRow2 = new PdfPCell(p2); formatCellBorder(cellRow1, 20); formatCellBorder(cellRow2, 20); cellRow1.setBorderWidthLeft(1); cellRow2.setBorderWidthRight(1); table.addCell(cellRow1); table.addCell(cellRow2); p1 = new Paragraph(space, "ISAPRE: " + patientIsapre, type); p2 = new Paragraph(space, "DOMICILIO: " + home, type); cellRow1 = new PdfPCell(p1); cellRow2 = new PdfPCell(p2); formatCellBorder(cellRow1, 20); formatCellBorder(cellRow2, 20); cellRow1.setBorderWidthLeft(1); cellRow2.setBorderWidthRight(1); table.addCell(cellRow1); table.addCell(cellRow2); p1 = new Paragraph(space, "COMUNA: " + commune, type); p2 = new Paragraph(space, "REGION: " + region, type); cellRow1 = new PdfPCell(p1); cellRow2 = new PdfPCell(p2); formatCellBorder(cellRow1, 20); formatCellBorder(cellRow2, 20); cellRow1.setBorderWidthLeft(1); cellRow2.setBorderWidthRight(1); table.addCell(cellRow1); table.addCell(cellRow2); p1 = new Paragraph(space, "N TELFONO FIJO: " + phoneNumber, type); p2 = new Paragraph(space, "N TELFONO CELULAR: " + celularNumber, type); cellRow1 = new PdfPCell(p1); cellRow2 = new PdfPCell(p2); formatCellBorder(cellRow1, 20); formatCellBorder(cellRow2, 20); cellRow1.setBorderWidthLeft(1); cellRow2.setBorderWidthRight(1); table.addCell(cellRow1); table.addCell(cellRow2); p1 = new Paragraph(space, "DIRECCIN CORREO ELECTRNICO (E-MAIL): " + mail, type); cellRow1 = new PdfPCell(p1); cellRow1.setColspan(2); formatCellBorder(cellRow1, 20); cellRow1.setBorderWidthLeft(1); cellRow1.setBorderWidthRight(1); cellRow1.setBorderWidthBottom(1); table.addCell(cellRow1); document.add(table); document.add(new Paragraph("\n")); //row 4 table = new PdfPTable(2); table.setWidthPercentage(100); p1 = new Paragraph(space, "INFORMACIN MDICA", subTitle); cellRow1 = new PdfPCell(p1); cellRow1.setColspan(2); formatCellBorder(cellRow1, 20); cellRow1.setBorderWidthTop(1); cellRow1.setBorderWidthLeft(1); cellRow1.setBorderWidthRight(1); cellRow1.setBorderWidthBottom(1); table.addCell(cellRow1); p1 = new Paragraph(space, "CONFIRMACIN DIAGNSTICA GES:", type); cellRow1 = new PdfPCell(p1); cellRow1.setColspan(2); formatCellBorder(cellRow1, 20); cellRow1.setBorderWidthLeft(1); cellRow1.setBorderWidthRight(1); table.addCell(cellRow1); p1 = new Paragraph(space, ges, type); cellRow1 = new PdfPCell(p1); cellRow1.setColspan(2); formatCellBorder(cellRow1, 20); cellRow1.setBorderWidthLeft(1); cellRow1.setBorderWidthRight(1); table.addCell(cellRow1); p1 = new Paragraph(space, "( ) Confirmacin Diagnstica", type); p2 = new Paragraph(space, "( ) Paciente en Tratamiento", type); cellRow1 = new PdfPCell(p1); cellRow2 = new PdfPCell(p2); formatCellBorder(cellRow1, 20); formatCellBorder(cellRow2, 20); cellRow1.setBorderWidthLeft(1); cellRow2.setBorderWidthRight(1); cellRow1.setBorderWidthBottom(1); cellRow2.setBorderWidthBottom(1); table.addCell(cellRow1); table.addCell(cellRow2); document.add(table); //row 5 document.add(new Paragraph(space, "CONSTANCIA", subTitle)); Paragraph text1 = new Paragraph(space, "Declaro que, con esta fecha y hora, he tomado conocimiento que tengo derecho a acceder a las Garantas Explcitas en Salud, siempre que la atencin sea otorgada en la red de Prestadores que me corresponde segn Fonasa o Isapre, a la que me encuentro adscrito", type); text1.setAlignment(Element.ALIGN_JUSTIFIED); document.add(text1); document.add(new Paragraph(space, "IMPORTANTE", subTitle)); Paragraph text2 = new Paragraph(space, "Tenga presente que s no se cumplen las garantas usted puede reclamar ante Fonasa o la Isapre, segn corresponda. Si la respuesta no es satisfactoria, usted puede recurrir en segunda instancia a la Superintendencia de Salud.", type); text2.setAlignment(Element.ALIGN_JUSTIFIED); document.add(text2); document.add(new Paragraph(space, "FECHA Y HORA DE NOTIFICACIN: " + "-", subTitle)); document.add(new Paragraph(space, "\n", type)); document.add(new Paragraph(space, "\n", type)); document.add(new Paragraph(space, "\n", type)); //row 6 table = new PdfPTable(2); table.setWidthPercentage(100); p1 = new Paragraph(space, "INFORM DIAGNSTICO GES", subTitle); p2 = new Paragraph(space, "TOM CONOCIMIENTO", subTitle); cellRow1 = new PdfPCell(p1); cellRow2 = new PdfPCell(p2); formatCellBorder(cellRow1, 20); formatCellBorder(cellRow2, 20); table.addCell(cellRow1); table.addCell(cellRow2); p1 = new Paragraph(space, "(Firma de persona que notifica)", subTitle2); p2 = new Paragraph(space, "(Firma o huella digital representante)", subTitle2); cellRow1 = new PdfPCell(p1); cellRow2 = new PdfPCell(p2); formatCellBorder(cellRow1, 20); formatCellBorder(cellRow2, 20); table.addCell(cellRow1); table.addCell(cellRow2); document.add(table); //row 7 document.add(new Paragraph(space, "En caso que la persona que tom conocimiento no sea el paciente, identificar.", type)); //row 8 table = new PdfPTable(2); table.setWidthPercentage(100); p1 = new Paragraph(space, "Nombre:", type); p2 = new Paragraph(space, "R.U.T:", type); cellRow1 = new PdfPCell(p1); cellRow2 = new PdfPCell(p2); formatCellBorder(cellRow1, 20); formatCellBorder(cellRow2, 20); table.addCell(cellRow1); table.addCell(cellRow2); p1 = new Paragraph(space, "N Telfono Celular:", type); p2 = new Paragraph(space, "Direccin correo electrnico (e-mail):", type); cellRow1 = new PdfPCell(p1); cellRow2 = new PdfPCell(p2); formatCellBorder(cellRow1, 20); formatCellBorder(cellRow2, 20); table.addCell(cellRow1); table.addCell(cellRow2); document.add(table); document.close(); } catch (DocumentException de) { throw new IOException(de.getMessage()); } }
From source file:Modelo.CotizacionDAO.java
public void writePdf(OutputStream outputStream, Cotizacion x, int idcotizacion) throws Exception { DateFormat df = new SimpleDateFormat("dd/MM/YYYY"); Calendar cdos = Calendar.getInstance(); Date datediamas = new Date(); Date dateaniomas = new Date(); cdos.add(Calendar.DATE, 1);/* w w w . j a va 2s. co m*/ datediamas = cdos.getTime(); String fechadiamas = df.format(datediamas); cdos.add(Calendar.YEAR, 1); dateaniomas = cdos.getTime(); String fechavencimiento = df.format(dateaniomas); Document document = new Document(PageSize.LETTER, 50, 50, 50, 30); Font boldFontTitulo = new Font(Font.FontFamily.HELVETICA, 12, Font.BOLD); Font boldFontTexto = new Font(Font.FontFamily.HELVETICA, 10, Font.BOLD); Font FontTexto = new Font(Font.FontFamily.HELVETICA, 10); // document.setPageSize(null); PdfWriter writer = PdfWriter.getInstance(document, outputStream); Image imagen = Image.getInstance("http://54.67.56.185/BSeguros_pa18/img/BSeguroLogo.png"); // Image imagen = Image.getInstance("D:\\ALEX\\Bseguros\\web\\img\\Aseguradoras\\BSeguroLogo.png"); Image imagen2 = Image.getInstance( "http://54.67.56.185/BSeguros_pa18/img/Aseguradoras/" + x.getId_aseguradora() + ".png"); //Image imagen2 = Image.getInstance("D:\\ALEX\\Bseguros\\web\\img\\Aseguradoras\\Mapfre.png"); document.open(); PdfContentByte canvas = writer.getDirectContent(); Rectangle rect = new Rectangle(36, 36, 579, 756); rect.setBorder(Rectangle.BOX); rect.setBorderWidth(2); canvas.rectangle(rect); document.addTitle("Cotizacion"); document.addSubject("Cotizacion"); document.addKeywords("Cotizacion, seguros"); document.addAuthor("BSeguro"); document.addCreator("Bseguro"); imagen.scaleAbsoluteHeight(30f); imagen.setAbsolutePosition(45f, 720f); imagen2.scaleAbsoluteHeight(30f); imagen2.setAbsolutePosition(450f, 720f); document.add(imagen); document.add(imagen2); Paragraph paragraph2 = new Paragraph("DATOS DE TU POLIZA", boldFontTitulo); paragraph2.setAlignment(Element.ALIGN_CENTER); document.add(paragraph2); //creas una tabla con un ancho de 3 celdas, el salto a la siguiente fila sera automatico PdfPTable table = new PdfPTable(3); table.getDefaultCell().setBorder(0); PdfPCell cell; Paragraph saltodelinea = new Paragraph(" "); document.add(saltodelinea); document.add(new Paragraph(" Datos de tu poliza folio: " + "BC" + x.getId_aseguradora().substring(0, 1) + x.getMetododepago().substring(0, 1) + ": 0000" + idcotizacion, boldFontTitulo)); document.add(new Paragraph(" Vigencia de la poliza del: " + fechadiamas + " al: " + fechavencimiento, boldFontTitulo)); document.add(saltodelinea); document.add(new Paragraph(" Datos del Contratante: ", boldFontTitulo)); //document.add(saltodelinea); //agrego otra tabla table = new PdfPTable(6); table.setWidthPercentage(100); table.getDefaultCell().setBorder(0); table.addCell(new Paragraph("Nombre: ", boldFontTexto)); PdfPCell celdaNombre = new PdfPCell( new Paragraph(x.getNombre_contratante() + " " + x.getApellido_paterno(), FontTexto)); celdaNombre.setColspan(5); celdaNombre.setBorder(0); table.addCell(celdaNombre); table.addCell(new Paragraph("RFC : ", boldFontTexto)); PdfPCell celdaRFC = new PdfPCell(new Paragraph(x.getRfc(), FontTexto)); celdaRFC.setColspan(5); celdaRFC.setBorder(0); table.addCell(celdaRFC); table.addCell(new Paragraph("Direccion: ", boldFontTexto)); PdfPCell celdaDir = new PdfPCell( new Paragraph(x.getCall() + ", " + x.getNo_ext() + ", " + x.getNo_int() + ", " + x.getColonia() + ", " + x.getDelegacion() + ", " + x.getEstado() + ", " + x.getCp(), FontTexto)); celdaDir.setColspan(5); celdaDir.setBorder(0); table.addCell(celdaDir); table.addCell(new Paragraph("Email: ", boldFontTexto)); table.addCell(AddCell(x.getMail(), 5)); table.addCell(new Paragraph("Telefono ", boldFontTexto)); PdfPCell celdaTel = new PdfPCell(new Paragraph(x.getTelefono(), FontTexto)); celdaTel.setColspan(5); celdaTel.setBorder(0); table.addCell(celdaTel); document.add(table); document.add(saltodelinea); document.add(new Paragraph(" Datos del Vehiculo: ", boldFontTitulo)); // document.add(saltodelinea); //agrego otra tabla table = new PdfPTable(6); table.setWidthPercentage(100); table.getDefaultCell().setBorder(0); table.addCell(new Paragraph("Marca: ", boldFontTexto)); table.addCell(AddCell(x.getId_marca(), 5)); table.addCell(new Paragraph("Modelo:", boldFontTexto)); table.addCell(AddCell(x.getId_anio().toString(), 5)); table.addCell(new Paragraph("Tipo: ", boldFontTexto)); table.addCell(AddCell(x.getId_submarca(), 5)); table.addCell(new Paragraph("Version: ", boldFontTexto)); table.addCell(AddCell(x.getId_modelo(), 5)); table.addCell(new Paragraph("No. De Serie: ", boldFontTexto)); table.addCell(AddCell(x.getSerie(), 5)); document.add(table); document.add(saltodelinea); document.add(new Paragraph(" Informacion de la Poliza: ", boldFontTitulo)); // document.add(saltodelinea); //agrego otra tabla table = new PdfPTable(6); table.setWidthPercentage(100); table.getDefaultCell().setBorder(0); table.addCell(new Paragraph("Pago: ", boldFontTexto)); table.addCell(AddCell(x.getTipo_pago(), 5)); table.addCell(new Paragraph("Aseguradora: ", boldFontTexto)); table.addCell(AddCell(x.getId_aseguradora(), 5)); document.add(table); document.add(saltodelinea); document.add(new Paragraph(" Detalles de la Cobertura: Cobertura Amplia ", boldFontTitulo)); // document.add(saltodelinea); //agrego otra tabla table = new PdfPTable(3); table.setWidthPercentage(100); table.getDefaultCell().setBorder(0); table.addCell(new Paragraph("Cobertura ", boldFontTexto)); table.addCell(new Paragraph("Responsabilidad Civil", boldFontTexto)); table.addCell(new Paragraph("Deducible ", boldFontTexto)); table.addCell(new Paragraph("Daos Materiales", FontTexto)); table.addCell(new Paragraph("Valor Comercial", FontTexto)); table.addCell(new Paragraph("5%", FontTexto)); table.addCell(new Paragraph("Robo Total", FontTexto)); table.addCell(new Paragraph("Valor Comercial", FontTexto)); table.addCell(new Paragraph("10%", FontTexto)); table.addCell(new Paragraph("Responsabilidad Civil", FontTexto)); table.addCell(new Paragraph("$4,000,000.00", FontTexto)); table.addCell(new Paragraph("", FontTexto)); table.addCell(new Paragraph("Gastos Medicos Ocupantes", FontTexto)); table.addCell(new Paragraph("$500,000.00", FontTexto)); table.addCell(new Paragraph("", FontTexto)); table.addCell(new Paragraph("Asistencia Legal", FontTexto)); table.addCell(new Paragraph("Amparada", FontTexto)); table.addCell(new Paragraph("", FontTexto)); table.addCell(new Paragraph("Asistencia Vial", FontTexto)); table.addCell(new Paragraph("Amparada", FontTexto)); table.addCell(new Paragraph("", FontTexto)); document.add(table); document.add(saltodelinea); document.add(new Paragraph(" Informacion del Pago ", boldFontTitulo)); document.add(new Paragraph(" Instrumento de Pago: " + x.getMetododepago(), boldFontTexto)); //agrego otra tabla table = new PdfPTable(6); table.setWidthPercentage(100); table.getDefaultCell().setBorder(0); table.addCell(AddCell("Concepto ", 2)); table.addCell(AddCell("Monto", 4)); table.addCell(AddCell("Prima Total ", 2)); table.addCell(AddCell(x.getMonto(), 4)); table.addCell(AddCell("Prima Inicial", 2)); table.addCell(AddCell(x.getMonto(), 4)); table.addCell(AddCell("Pago Subsecuente ", 2)); table.addCell(AddCell("0", 4)); document.add(table); document.add(saltodelinea); if (x.getCobertura_auto_siempre() == true) { document.add(new Paragraph(" Informacion de Modulos HDI ", boldFontTitulo)); table = new PdfPTable(6); table.setWidthPercentage(100); table.getDefaultCell().setBorder(0); table.addCell(AddCell("Modulos ", 2)); table.addCell(AddCell("Contratados", 4)); table.addCell(AddCell("HDI - Autos por Siempre ", 2)); table.addCell(AddCell("$ 1,799.00", 4)); document.add(table); } else { if (x.getCobertura_auto_amante() == true) { document.add(new Paragraph(" Informacion de Modulos HDI ", boldFontTitulo)); table = new PdfPTable(6); table.setWidthPercentage(100); table.getDefaultCell().setBorder(0); table.addCell(AddCell("Modulos ", 2)); table.addCell(AddCell("Contratados", 4)); table.addCell(AddCell("HDI - Amante de los Autos ", 2)); table.addCell(AddCell("$ 1,799.00", 4)); document.add(table); } else { } document.add(saltodelinea); } document.add(new Paragraph("* Estaras asegurado a partir de las 12 horas del siguiente dia habil.", boldFontTexto)); document.close(); }
From source file:modelo.Ejemplo1.java
/** * Raz./* ww w . j a v a2s . c o m*/ */ public static void main(String[] args) { //Creamos la representacin de una pgina, con un tamao //por defecto. Rectangle pagina = new Rectangle(PageSize.LETTER); //Establecemos el color de la pgina y reescribimos la funcin //toString de la clase BaseColor para obtener el nombre del color. // Creamos un documento y le pasamos como parametro un objeto de // tipo Rectangle, dicho objeto contiene las especificaciones // de como se vera nuestra pgina. Document documento = new Document(pagina); try { // Obtenemos una instancia de un objeto PDFWriter PdfWriter.getInstance(documento, new FileOutputStream("Ejemplo1.pdf")); documento.open(); // Generamos nuestro contenido. String contenido = "Generacin de un PDF simple:\n " + "\t\tAncho de pgina: " + documento.getPageSize().getWidth() + "\n\t\tAlto de pgina: " + documento.getPageSize().getHeight() + "\n\t\tColor de pgina: "; // Lo agregamos al documento por medio de una instancia // de un obtjeto Paragraph. // documento.add(new Paragraph(contenido)); // Cerramos el documento para hacer persistente el contenido. documento.close(); } catch (DocumentException ex) { // Atrapamos excepciones concernientes al documento. } catch (java.io.IOException ex) { // Atrapamos excepciones concernientes al I/O. } }
From source file:modelo.plantillaPDF.java
public void pdf(int tiquet, int idOrden, String codOrden) { try {/*from ww w. j a va 2s . co m*/ String sql = "Select * from tiquet where idorden = '" + idOrden + "' and tiquet='" + tiquet + "'"; rs = Consultar(sql); int id = 0; int numTiquet = 0; String ob = ""; tiquet verTiquet = new tiquet(); colores verColor = new colores(); String colorUno = ""; String colorDos = ""; System.out.print("id de la orden en el tiquet:" + idOrden); ArrayList<String> lista = new ArrayList<String>(); int c1 = 0, c2 = 0, c3 = 0, c4 = 0, c5 = 0, c6 = 0, c7 = 0, c8 = 0, c9 = 0, c10 = 0, c11 = 0, c12 = 0, c13 = 0, c14 = 0, c15 = 0; int c16 = 0, c17 = 0, c18 = 0, c19 = 0, c20 = 0, c21 = 0, c22 = 0, c23 = 0, c24 = 0, c25 = 0, c26 = 0, c27 = 0, c28 = 0, c29 = 0; int c30 = 0, c31 = 0, c32 = 0; //rs.last(); int cuantos = rs.getRow(); //System.out.print("puestos:" + cuantos+ "orden: " + codOrden + "tiquet: " + tiquet); //Fecha actual en formato completo: //Tue Sep 23 01:18:48 CEST 2014 Date fechaActual = new Date(); // System.out.println(fechaActual); // System.out.println("---------------------------------------------"); //Formateando la fecha: DateFormat formatoHora = new SimpleDateFormat("HH-mm-ss"); DateFormat formatoFecha = new SimpleDateFormat("yyyy-MM-dd"); DateFormat Fecha = new SimpleDateFormat("dd/MM/yyyy"); // System.out.println("Fecha: "+formatoFecha.format(fechaActual)+" Son las: "+formatoHora.format(fechaActual)); //Directorio destino para las descargas File folder = new File("c:\\seiya\\tiquets"); //Crea el directorio de destino en caso de que no exista folder.mkdirs(); String fe = Fecha.format(fechaActual); int numeroAleatorio = (int) (Math.random() * 2500 + 1); //Nombre del fichero <strong>PDF</strong> Resultante de la ejecucion String dir = "C:\\seiya\\tiquets\\Tiquet_" + tiquet + ".pdf"; ; // El archivo pdf que vamos a generar FileOutputStream fileOutputStream = new FileOutputStream(dir); //Creacion del documento con un tamao y unos margenes predeterminados Document document = new Document(PageSize.LETTER, 10, 10, 10, 1); //A DocWriter class for PDF con Java. //When this PdfWriter is added to a certain PdfDocument, //the <strong>PDF</strong> representation of every Element added to this Document will be written to the outputstream. //PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(RESULT)); // Obtener la instancia del PdfWriter PdfWriter writer = PdfWriter.getInstance(document, fileOutputStream); //LEADING = separacion entre lineas del documento writer.setInitialLeading(16); Rectangle rct = new Rectangle(36, 54, 559, 788); //Definimos un nombre y un tamao para el PageBox los nombres posibles son: crop?, trim?, art? and bleed?. writer.setBoxSize("art", rct); //Opens the document. //You have to open the document before you can begin to add content to the body of the document. document.open(); //************************************************************** //Ejemplos de TABLE //Aadir tabla 15 columnas PdfPTable table = new PdfPTable(15); // PdfPTable tabla = new PdfPTable(15); PdfPCell celda; //Aadir CABECERA PdfPCell cell; Image image = Image.getInstance("logo/logo.png"); // String col = "jhon"; cell = new PdfPCell(image); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(4); cell.setRowspan(7); table.addCell(cell); cell = new PdfPCell(new Phrase("Calle 12 # 6-68 Nia Ceci")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(6); cell.setRowspan(2); table.addCell(cell); while (rs.next()) { c1 = rs.getInt(1); c2 = rs.getInt(2); c3 = rs.getInt(3); c4 = rs.getInt(4); c5 = rs.getInt(5); c6 = rs.getInt(8); c7 = rs.getInt(9); c8 = rs.getInt(10); c9 = rs.getInt(11); c10 = rs.getInt(12); c11 = rs.getInt(13); c12 = rs.getInt(14); c13 = rs.getInt(15); c14 = rs.getInt(16); c15 = rs.getInt(17); c16 = rs.getInt(18); c17 = rs.getInt(19); c18 = rs.getInt(21); c19 = rs.getInt(22); c20 = rs.getInt(23); c21 = rs.getInt(24); c22 = rs.getInt(25); c23 = rs.getInt(26); c24 = rs.getInt(28); c25 = rs.getInt(29); c26 = rs.getInt(30); c27 = rs.getInt(31); c28 = rs.getInt(32); colorUno = verColor.consultarNombreColorUno(c4); colorDos = verColor.consultarNombreColorDos(c5); ob = verTiquet.ConsultaObservacion(tiquet); System.out.print("Color Uno: " + colorUno); //cell.setBackgroundColor(BaseColor.BLUE); table.addCell(cell); cell = new PdfPCell(new Phrase("TIKET #:")); cell.setColspan(2); cell.setRowspan(2); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); //cell.setBackgroundColor(BaseColor.GRAY); table.addCell(cell); cell = new PdfPCell(new Phrase("" + tiquet)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); //cell.setBackgroundColor(BaseColor.ORANGE); cell.setColspan(3); cell.setRowspan(2); table.addCell(cell); //Aadir dos filas de celdas sin formato cell = new PdfPCell(new Phrase("Tel: 5783364")); cell.setColspan(6); cell.setRowspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); //cell.setBackgroundColor(BaseColor.CYAN); table.addCell(cell); cell = new PdfPCell(new Phrase("REF:")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); //cell.setBackgroundColor(BaseColor.ORANGE); cell.setColspan(2); cell.setRowspan(2); table.addCell(cell); cell = new PdfPCell(new Phrase("" + c6)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); //cell.setBackgroundColor(BaseColor.ORANGE); cell.setColspan(3); cell.setRowspan(2); table.addCell(cell); cell = new PdfPCell(new Phrase("calzadoseiya@gmail.com")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(6); cell.setRowspan(2);//para eliminar espacio cabecera reemplazo el 2 por 3 table.addCell(cell); cell = new PdfPCell(new Phrase("PARES:")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); //cell.setBackgroundColor(BaseColor.ORANGE); cell.setColspan(2); cell.setRowspan(2); table.addCell(cell); cell = new PdfPCell(new Phrase("" + c7)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); //cell.setBackgroundColor(BaseColor.ORANGE); cell.setColspan(3); cell.setRowspan(2); table.addCell(cell); cell = new PdfPCell(new Phrase("FECHA"));//espacio intermedio cabecera cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(2); table.addCell(cell); cell = new PdfPCell(new Phrase(fe));//espacio intermedio cabecera cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(4); table.addCell(cell); cell = new PdfPCell(new Phrase("ORDEN:")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); //cell.setBackgroundColor(BaseColor.ORANGE); cell.setColspan(2); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase("" + codOrden)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); //cell.setBackgroundColor(BaseColor.ORANGE); cell.setColspan(3); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase("CORTADA")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(4); table.addCell(cell); cell = new PdfPCell(new Phrase("")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(11); cell.setRowspan(1); table.addCell(cell); cell = new PdfPCell(new Phrase("GUARNICION")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(4); table.addCell(cell); cell = new PdfPCell(new Phrase("")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(11); table.addCell(cell); cell = new PdfPCell(new Phrase("MONTADA")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(4); table.addCell(cell); cell = new PdfPCell(new Phrase("")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(11); table.addCell(cell); cell = new PdfPCell(new Phrase("EMPLANTILLADA")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(4); table.addCell(cell); cell = new PdfPCell(new Phrase("")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(11); table.addCell(cell); cell = new PdfPCell(new Phrase("COLOR 1:")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(3); table.addCell(cell); cell = new PdfPCell(new Phrase(colorUno)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(4); table.addCell(cell); cell = new PdfPCell(new Phrase("COLOR 2:")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(3); table.addCell(cell); cell = new PdfPCell(new Phrase(colorDos)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(5); table.addCell(cell); cell = new PdfPCell(new Phrase("OBSERVACION")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(4); cell.setRowspan(2); table.addCell(cell); cell = new PdfPCell(new Phrase(ob)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(11); cell.setRowspan(2); table.addCell(cell); table.addCell("21"); table.addCell("22"); table.addCell("23"); table.addCell("24"); table.addCell("25"); table.addCell("26"); table.addCell("27"); table.addCell("28"); table.addCell("29"); table.addCell("30"); table.addCell("31"); table.addCell("32"); table.addCell("33"); table.addCell("34"); table.addCell("35"); table.addCell(" " + c8); table.addCell(" " + c9); table.addCell(" " + c10); table.addCell(" " + c11); table.addCell(" " + c12); table.addCell(" " + c13); table.addCell(" " + c14); table.addCell(" " + c15); table.addCell(" " + c16); table.addCell(" " + c17); table.addCell(" " + c18); table.addCell(" " + c19); table.addCell(" " + c20); table.addCell(" " + c21); table.addCell(" " + c22); table.addCell("36"); table.addCell("37"); table.addCell("38"); table.addCell("39"); table.addCell("40"); table.addCell("41"); table.addCell("42"); table.addCell("43"); table.addCell("44"); table.addCell(" "); table.addCell(" "); table.addCell(" "); table.addCell(" "); table.addCell(" "); table.addCell(" "); table.addCell(" " + c23); table.addCell(" " + c24); table.addCell(" " + c25); table.addCell(" " + c26); table.addCell(" " + c27); table.addCell(" " + c28); table.addCell(" " + c29); table.addCell(" " + c30); table.addCell(" " + c31); table.addCell(" "); table.addCell(" "); table.addCell(" "); table.addCell(" "); table.addCell(" "); table.addCell(" "); document.add(table); String cadena = ""; for (int i = 1; i <= 4; i++) { //Chunk chunkSeparador = new Chunk(SEPARADOR); // document.add(chunkSeparador); // document.add(Chunk.NEWLINE); PdfPTable tabla = new PdfPTable(15); if (i == 1) cadena = "EMPLANTILLADA"; if (i == 2) cadena = "MONTADA"; if (i == 3) { cadena = "GUARNICION"; } if (i == 4) cadena = "CORTADA"; cell = new PdfPCell( new Phrase("------------------------------------------------------------------------")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(15); cell.setRowspan(1); tabla.addCell(cell); cell = new PdfPCell(new Phrase("CALZADO SEIYA")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(5); cell.setRowspan(1); tabla.addCell(cell); cell = new PdfPCell(new Phrase(cadena)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(4); cell.setRowspan(1); tabla.addCell(cell); cell = new PdfPCell(new Phrase("TIQUET #")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(3); cell.setRowspan(1); tabla.addCell(cell); cell = new PdfPCell(new Phrase("" + tiquet)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(3); cell.setRowspan(1); tabla.addCell(cell); cell = new PdfPCell(new Phrase("PARES:")); cell.setHorizontalAlignment(Font.BOLD); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(2); cell.setRowspan(1); tabla.addCell(cell); cell = new PdfPCell(new Phrase("" + c7)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(3); cell.setRowspan(1); tabla.addCell(cell); cell = new PdfPCell(new Phrase("")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(4); cell.setRowspan(1); tabla.addCell(cell); cell = new PdfPCell(new Phrase("REF:")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(3); cell.setRowspan(1); tabla.addCell(cell); cell = new PdfPCell(new Phrase("" + c6)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(3); cell.setRowspan(1); tabla.addCell(cell); cell = new PdfPCell(new Phrase("COLOR 1:")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(3); tabla.addCell(cell); cell = new PdfPCell(new Phrase(colorUno)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(4); tabla.addCell(cell); cell = new PdfPCell(new Phrase("COLOR 2:")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(3); tabla.addCell(cell); cell = new PdfPCell(new Phrase(colorDos)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(5); tabla.addCell(cell); tabla.addCell("21"); tabla.addCell("22"); tabla.addCell("23"); tabla.addCell("24"); tabla.addCell("25"); tabla.addCell("26"); tabla.addCell("27"); tabla.addCell("28"); tabla.addCell("29"); tabla.addCell("30"); tabla.addCell("31"); tabla.addCell("32"); tabla.addCell("33"); tabla.addCell("34"); tabla.addCell("35"); tabla.addCell(" " + c8); tabla.addCell(" " + c9); tabla.addCell(" " + c10); tabla.addCell(" " + c11); tabla.addCell(" " + c12); tabla.addCell(" " + c13); tabla.addCell(" " + c14); tabla.addCell(" " + c15); tabla.addCell(" " + c16); tabla.addCell(" " + c17); tabla.addCell(" "); tabla.addCell(" " + c20); tabla.addCell(" " + c21); tabla.addCell(" " + c22); tabla.addCell(" " + c23); tabla.addCell("36"); tabla.addCell("37"); tabla.addCell("38"); tabla.addCell("39"); tabla.addCell("40"); tabla.addCell("41"); tabla.addCell("42"); tabla.addCell("43"); tabla.addCell("44"); tabla.addCell(" "); tabla.addCell(" "); tabla.addCell(" "); tabla.addCell(" "); tabla.addCell(" "); tabla.addCell(" "); tabla.addCell(" " + c24); tabla.addCell(" " + c25); tabla.addCell(" " + c26); tabla.addCell(" " + c27); tabla.addCell(" " + c28); tabla.addCell(" " + c29); tabla.addCell(" " + c30); tabla.addCell(" " + c31); tabla.addCell(" " + c32); tabla.addCell(" "); tabla.addCell(" "); tabla.addCell(" "); tabla.addCell(" "); tabla.addCell(" "); tabla.addCell(" "); document.add(tabla); } //document.add(new Paragraph(new Date().toString())); //FIN Ejemplos de TABLE //************************************************************** //************************************************************** // Cierre del documento document.close(); } } catch (Exception ex) { System.out.println(ex.getMessage()); } }
From source file:Modelo.RelatoriosBEAN.java
public static void relatorioTopJogos() throws FileNotFoundException, DocumentException { String path = System.getProperty("user.home") + FRMEmitirRelatorios.local + ".pdf"; Document document = new Document(PageSize.LETTER); PdfWriter.getInstance(document, new FileOutputStream(path)); document.open();//from w w w .j a va2 s. c o m document.addAuthor("TechSales"); document.addCreator("TechSales"); document.addSubject("TechSales - Sistema de gerenciamento de locadoras"); document.addCreationDate(); document.addTitle("TechSales"); HTMLWorker htmlWorker = new HTMLWorker(document); String frase; try { frase = "<html>" + "<head> <meta charset=\"utf-8\"> </head>" + "<body>" + "<br/>" + "<h1 align=center>Relatrio de Jogos mais vendidos</h1>" + "<br/><br/>" + "<table BORDER RULES=rows border=0 style=\" width:100%; \">\n" + "<tr> " + "<th align=center><strong>Cdigo</strong></th> " + "<th align=center><strong>Nome do Jogo</strong></th> " + "<th align=center><strong>Quantidade Vendida</strong></th> " + "<th align=center><strong>Valor Total</strong></th> " + "</tr> "; for (JogoBEAN j : jDAO.topJogos()) { frase += "<tr align=center><td>" + j.getJoCodigo() + "</td><td>" + j.getJoNome() + "</td><td>" + j.getJoQtd() + "</td><td>" + j.getJoPrecoPadrao() + "</td></tr>"; } frase += "</table>"; frase += "</body></html>"; htmlWorker.parse(new StringReader(frase)); document.close(); if (Desktop.isDesktopSupported()) { try { Desktop.getDesktop().open(new File(path)); } catch (Exception e) { JOptionPane.showMessageDialog(null, e); } } } catch (Exception e) { e.printStackTrace(); } }
From source file:Modelo.RelatoriosBEAN.java
public static void relatorioWorstJogos() throws FileNotFoundException, DocumentException { String path = System.getProperty("user.home") + FRMEmitirRelatorios.local + ".pdf"; Document document = new Document(PageSize.LETTER); PdfWriter.getInstance(document, new FileOutputStream(path)); document.open();/* ww w . j a v a 2 s . c o m*/ document.addAuthor("TechSales"); document.addCreator("TechSales"); document.addSubject("TechSales - Sistema de gerenciamento de locadoras"); document.addCreationDate(); document.addTitle("TechSales"); HTMLWorker htmlWorker = new HTMLWorker(document); String frase; try { frase = "<html>" + "<head> <meta charset=\"utf-8\"> </head>" + "<body>" + "<br/>" + "<h1 align=center>Relatrio de Jogos menos vendidos </h1>" + "<br/><br/>" + "<table BORDER RULES=rows border=0 style=\" width:100%; \">\n" + "<tr> " + "<th align=center><strong>Cdigo</strong></th> " + "<th align=center><strong>Nome do Jogo</strong></th> " + "<th align=center><strong>Quantidade Vendida</strong></th> " + "<th align=center><strong>Valor Total</strong></th> " + "</tr> "; for (JogoBEAN j : jDAO.worstJogos()) { frase += "<tr align=center><td>" + j.getJoCodigo() + "</td><td>" + j.getJoNome() + "</td><td>" + j.getJoQtd() + "</td><td>" + j.getJoPrecoPadrao() + "</td></tr>"; } frase += "</table>"; frase += "</body></html>"; htmlWorker.parse(new StringReader(frase)); document.close(); if (Desktop.isDesktopSupported()) { try { Desktop.getDesktop().open(new File(path)); } catch (Exception e) { JOptionPane.showMessageDialog(null, e); } } } catch (Exception e) { e.printStackTrace(); } }
From source file:Modelo.RelatoriosBEAN.java
public static void relatorioTopAlugueis() throws FileNotFoundException, DocumentException { String path = System.getProperty("user.home") + FRMEmitirRelatorios.local + ".pdf"; Document document = new Document(PageSize.LETTER); PdfWriter.getInstance(document, new FileOutputStream(path)); document.open();/*from w w w . j a va2 s .co m*/ document.addAuthor("TechSales"); document.addCreator("TechSales"); document.addSubject("TechSales - Sistema de gerenciamento de locadoras"); document.addCreationDate(); document.addTitle("TechSales"); HTMLWorker htmlWorker = new HTMLWorker(document); String frase; try { frase = "<html>" + "<head> <meta charset=\"utf-8\"> </head>" + "<body>" + "<br/>" + "<h1 align=center>Relatrio de Jogos mais Alugados </h1>" + "<br/><br/>" + "<table BORDER RULES=rows border=0 style=\" width:100%; \">\n" + "<tr> " + "<th align=center><strong>Cdigo</strong></th> " + "<th align=center><strong>Nome do Jogo</strong></th> " + "<th align=center><strong>Quantidade Alugada</strong></th> " + "<th align=center><strong>Valor Total</strong></th> " + "</tr> "; for (JogoBEAN j : jDAO.topAluguelJogos()) { frase += "<tr align=center><td>" + j.getJoCodigo() + "</td><td>" + j.getJoNome() + "</td><td>" + j.getJoQtd() + "</td><td>" + j.getJoPrecoPadrao() + "</td></tr>"; } frase += "</table>"; frase += "</body></html>"; htmlWorker.parse(new StringReader(frase)); document.close(); if (Desktop.isDesktopSupported()) { try { Desktop.getDesktop().open(new File(path)); } catch (Exception e) { JOptionPane.showMessageDialog(null, e); } } } catch (Exception e) { e.printStackTrace(); } }
From source file:Modelo.RelatoriosBEAN.java
public static void relatorioWorstAlugueis() throws FileNotFoundException, DocumentException { String path = System.getProperty("user.home") + FRMEmitirRelatorios.local + ".pdf"; Document document = new Document(PageSize.LETTER); PdfWriter.getInstance(document, new FileOutputStream(path)); document.open();/* w w w . j a va 2s. com*/ document.addAuthor("TechSales"); document.addCreator("TechSales"); document.addSubject("TechSales - Sistema de gerenciamento de locadoras"); document.addCreationDate(); document.addTitle("TechSales"); HTMLWorker htmlWorker = new HTMLWorker(document); String frase; try { frase = "<html>" + "<head> <meta charset=\"utf-8\"> </head>" + "<body>" + "<br/>" + "<h1 align=center>Relatrio de Jogos menos Alugados </h1>" + "<br/><br/>" + "<table BORDER RULES=rows border=0 style=\" width:100%; \">\n" + "<tr> " + "<th align=center><strong>Cdigo</strong></th> " + "<th align=center><strong>Nome do Jogo</strong></th> " + "<th align=center><strong>Quantidade Vendida</strong></th> " + "<th align=center><strong>Valor Total</strong></th> " + "</tr> "; for (JogoBEAN j : jDAO.topAluguelJogos()) { frase += "<tr align=center><td>" + j.getJoCodigo() + "</td><td>" + j.getJoNome() + "</td><td>" + j.getJoQtd() + "</td><td>" + j.getJoPrecoPadrao() + "</td></tr>"; } frase += "</table>"; frase += "</body></html>"; htmlWorker.parse(new StringReader(frase)); document.close(); if (Desktop.isDesktopSupported()) { try { Desktop.getDesktop().open(new File(path)); } catch (Exception e) { JOptionPane.showMessageDialog(null, e); } } } catch (Exception e) { e.printStackTrace(); } }