List of usage examples for com.itextpdf.text Paragraph Paragraph
public Paragraph()
Paragraph
. From source file:com.planning.project.controller.CreatePDF.java
private static void createTable(Document document) throws DocumentException, IOException { Font font = new Font(BaseFont.createFont("D:/THSarabunNew.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED)); font.setSize(16);/*ww w. java2 s . co m*/ Paragraph paragraph = new Paragraph(); paragraph.setFont(font); creteEmptyLine(paragraph, 2); document.add(paragraph); PdfPTable table = new PdfPTable(7); paragraph.add(""); PdfPCell c1 = new PdfPCell(new Phrase("asasas", font)); c1.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(c1); c1 = new PdfPCell(new Phrase("/?", font)); c1.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(c1); c1 = new PdfPCell(new Phrase("?", font)); c1.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(c1); TbActivity ac = new TbActivity(); c1 = new PdfPCell(new Phrase("", font)); c1.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(c1); c1 = new PdfPCell(new Phrase("", font)); c1.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(c1); c1 = new PdfPCell(new Phrase("", font)); c1.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(c1); c1 = new PdfPCell(new Phrase("", font)); c1.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(c1); table.setHeaderRows(1); paragraph.add(""); for (int i = 0; i < 7; i++) { table.setWidthPercentage(100); table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER); table.getDefaultCell().setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(paragraph); } document.add(table); }
From source file:com.planning.project.controller.CreatePDF.java
private static void createPagePDFFormProject(Document document, TbFormProject tbFormProject, List<TbActivity> activity, List<TbDetailSka> detailSka, List<TbDetailSm> detailSms, TbFormSubproject subProject) throws DocumentException, IOException { Font font = new Font(BaseFont.createFont("D:/THSarabunNew.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED)); font.setSize(16);/*from w ww . j av a2 s. c o m*/ int acNo = 0; Paragraph openning = new Paragraph(); Paragraph ska = new Paragraph(); Paragraph sms = new Paragraph(); Paragraph notice = new Paragraph(); Paragraph address = new Paragraph(); Paragraph readyTodo = new Paragraph(); readyTodo.setFont(font); address.setFont(font); ska.setFont(font); sms.setFont(font); notice.setFont(font); openning.setFont(font); openning.add(" : " + tbFormProject.getTbFaculty().getFacultyName()); creteEmptyLine(openning, 1); openning.add("?" + tbFormProject.getTbStrBud().getStrBudName()); creteEmptyLine(openning, 1); openning.add("? : " + tbFormProject.getTbPlan().getPlansName()); creteEmptyLine(openning, 1); openning.add("? : " + tbFormProject.getTbStrMin().getStrMinName()); creteEmptyLine(openning, 1); openning.add("? : " + tbFormProject.getTbMisUni().getMisUniName()); creteEmptyLine(openning, 1); openning.add(" : " + tbFormProject.getTbSubUni().getSubUniName()); creteEmptyLine(openning, 1); openning.add("? : " + tbFormProject.getTbProduct().getProductName()); creteEmptyLine(openning, 1); openning.add( "? : " + tbFormProject.getTbProjectname().getProjectnameName()); creteEmptyLine(openning, 1); openning.add("? : " + tbFormProject.getTbPerson().getPersonName() + " " + tbFormProject.getTbPerson().getPersonLastname()); creteEmptyLine(openning, 1); openning.add(" : " + tbFormProject.getTotal()); creteEmptyLine(openning, 1); openning.add("? : " + tbFormProject.getAllocateMoney()); creteEmptyLine(openning, 1); openning.add(" : " + (Long.parseLong(tbFormProject.getAllocateMoney()) - Long.parseLong(tbFormProject.getMoneyBalance()))); creteEmptyLine(openning, 1); openning.add(" : " + tbFormProject.getMoneyBalance()); creteLine(openning, 1); creteEmptyLine(openning, 1); for (TbActivity ac : activity) { acNo++; openning.add("??" + acNo + ":" + ac.getActivityName() + "?? : " + ac.getAddressName()); creteEmptyLine(openning, 1); openning.add("?? : " + ac.getStartdate() + "?? : " + ac.getEnddate()); creteEmptyLine(openning, 1); openning.add("? : " + ac.getAllocateMoney() + " : " + ac.getMoneyBalance()); creteEmptyLine(openning, 1); openning.add(" : " + (Long.parseLong(ac.getAllocateMoney()) - Long.parseLong(ac.getMoneyBalance()))); creteLine(openning, 1); creteEmptyLine(openning, 1); } ska.add(" ?? (?)"); creteEmptyLine(ska, 1); for (TbDetailSka de : detailSka) { ska.add(de.getTbSkaType().getSkaTypeName() + " : " + de.getTbSkaIndicatorsFac().getSkaIndicatorsFacName() + " : " + de.getTbSkaIndicatorsHouse().getSkaIndicatorsHouseName()); creteEmptyLine(ska, 1); } sms.add(" ??? ()"); creteEmptyLine(sms, 1); for (TbDetailSm sm : detailSms) { sms.add(sm.getTbSmsCategory().getSmsCategoryName() + " " + " " + sm.getTbSmsIndicator().getSmsIndicatorsName()); creteEmptyLine(sms, 1); } notice.add( " : ??????? ?????? "); creteEmptyLine(notice, 1); address.add("? : " + " : " + subProject.getTbAmphur().getAmphurTh() + " : " + subProject.getTbProvince().getProvinceTh()); creteEmptyLine(address, 1); readyTodo.add("?"); creteEmptyLine(readyTodo, 1); readyTodo.add("? : " + subProject.getTbApproPlaceType().getApproPlaceTypeName()); creteEmptyLine(readyTodo, 1); readyTodo.add("?/ : " + subProject.getTbApproPoint1().getApproPointName()); creteEmptyLine(readyTodo, 1); readyTodo.add("/? : " + subProject.getTbApproPoint2().getApproPointName()); creteEmptyLine(readyTodo, 1); readyTodo.add("?? : " + subProject.getTbApproProjectType().getApproProjectTypeName()); creteEmptyLine(readyTodo, 1); document.add(openning); document.add(ska); document.add(sms); document.add(notice); document.add(address); document.add(readyTodo); }
From source file:com.planning.project.controller.CreatePDF.java
private static void createPagePDFFormProject2(Document document, TbFormProject tbFormProject, List<TbActivity> activity, List<TbDetailSka> detailSka, List<TbDetailSm> detailSms, TbFormSubproject subProject) throws DocumentException, IOException { Font font = new Font(BaseFont.createFont("D:/THSarabunNew.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED)); font.setSize(16);//from w ww. j ava2 s .c om Paragraph openning = new Paragraph(); openning.setFont(font); creteLine(openning, 1); openning.add("??? "); creteEmptyLine(openning, 1); openning.add("????"); creteEmptyLine(openning, 1); openning.add("??? : " + subProject.getTbMonth1().getMonthLong()); creteEmptyLine(openning, 1); openning.add( "? : " + subProject.getTbMonth2().getMonthLong()); creteEmptyLine(openning, 1); openning.add( "??????? : " + subProject.getTbMonth3().getMonthLong()); creteEmptyLine(openning, 1); openning.add("??"); creteEmptyLine(openning, 1); openning.add( "? ???? : " + subProject.getTbMonth4().getMonthLong()); creteEmptyLine(openning, 1); openning.add( "??? : " + subProject.getTbMonth5().getMonthLong()); creteEmptyLine(openning, 1); openning.add( "//????? : " + subProject.getTbMonth6().getMonthLong()); creteEmptyLine(openning, 1); openning.add( "??? : ( 3 ?) : " + subProject.getWorkflowPlanBudget()); creteLine(openning, 1); creteEmptyLine(openning, 1); document.add(openning); }
From source file:com.planning.project.controller.CreatePDF.java
private static void createPagePDFFormProject3(Document document, TbFormProject tbFormProject, List<TbActivity> activity, List<TbDetailSka> detailSka, List<TbDetailSm> detailSms, TbFormSubproject subProject) throws DocumentException, IOException { Font font = new Font(BaseFont.createFont("D:/THSarabunNew.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED)); font.setSize(16);//from w w w . j a v a 2 s. co m Paragraph openning = new Paragraph(); openning.setFont(font); creteLine(openning, 1); creteEmptyLine(openning, 1); openning.add( "(?????)"); creteEmptyLine(openning, 1); openning.add(": " + tbFormProject.getResults()); creteEmptyLine(openning, 1); openning.add( "?/ ? ()"); creteEmptyLine(openning, 1); openning.add(": " + tbFormProject.getProblem()); creteEmptyLine(openning, 1); openning.add( "??/? ()"); creteEmptyLine(openning, 1); openning.add(": " + tbFormProject.getDevelopmentPlan()); creteEmptyLine(openning, 1); openning.add( "???"); creteEmptyLine(openning, 1); document.add(openning); openning.add( "?? (???? ? ? ??? ?? ?)"); creteEmptyLine(openning, 1); openning.add(": " + tbFormProject.getRiskPolitics()); creteEmptyLine(openning, 1); openning.add( "????/?"); creteEmptyLine(openning, 1); openning.add(": " + tbFormProject.getRiskDefPolitics()); creteLine(openning, 1); creteEmptyLine(openning, 1); openning.add( "??/? (??? ?/? /?? ?? ?)"); creteEmptyLine(openning, 1); openning.add(": " + tbFormProject.getRiskPolicy()); creteEmptyLine(openning, 1); openning.add( "????/?"); creteEmptyLine(openning, 1); openning.add(": " + tbFormProject.getRiskDefPolicy()); creteLine(openning, 1); creteEmptyLine(openning, 1); openning.add( "??? (? ??? ? ? ??)"); creteEmptyLine(openning, 1); openning.add(": " + tbFormProject.getRiskWorkflow()); creteEmptyLine(openning, 1); openning.add( "????/?"); creteEmptyLine(openning, 1); openning.add(": " + tbFormProject.getRiskDefWorkflow()); creteLine(openning, 1); creteEmptyLine(openning, 1); openning.add( "???? (? ?? ?????)"); creteEmptyLine(openning, 1); openning.add(": " + tbFormProject.getRiskFinance()); creteEmptyLine(openning, 1); openning.add( "????/?"); creteEmptyLine(openning, 1); openning.add(": " + tbFormProject.getRiskDefFinance()); creteLine(openning, 1); creteEmptyLine(openning, 1); openning.add( " (? ???)"); creteEmptyLine(openning, 1); openning.add(": " + tbFormProject.getRiskTechnology()); creteEmptyLine(openning, 1); openning.add( "????/?"); creteEmptyLine(openning, 1); openning.add(": " + tbFormProject.getRiskDefTechnology()); creteLine(openning, 1); creteEmptyLine(openning, 1); openning.add( "? (????? ?)"); creteEmptyLine(openning, 1); openning.add(": " + tbFormProject.getRiskEnvironment()); creteEmptyLine(openning, 1); openning.add( "????/?"); creteEmptyLine(openning, 1); openning.add(": " + tbFormProject.getRiskDefEnvironment()); creteLine(openning, 1); creteEmptyLine(openning, 1); document.add(openning); }
From source file:com.planning.project.controller.CreatePDF.java
private static void addTitlePageProject(Document document) throws DocumentException, IOException { Font font = new Font(BaseFont.createFont("D:/THSarabunNew.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED)); font.setSize(24);//from w w w . ja va2s . c o m String imagepath = "src/main/webapp/resources/images/logo.jpg"; Image img = Image.getInstance(imagepath); img.scaleToFit(70f, 70f); SimpleDateFormat simpleDateFormat = new SimpleDateFormat("MM/dd/yyyy"); Paragraph created = new Paragraph(); created.setFont(TIME_ROMAN_SMALL); created.add("Report created on " + simpleDateFormat.format(new Date())); created.setAlignment(Element.ALIGN_RIGHT); Paragraph logo = new Paragraph(); logo.setFont(TIME_ROMAN_SMALL); logo.add(img); logo.setAlignment(Element.ALIGN_LEFT); document.add(created); document.add(logo); // Paragraph created = new Paragraph(); // created.setFont(TIME_ROMAN_SMALL); // created.add("Report created on " + simpleDateFormat.format(new // Date())); // created.setAlignment(Element.ALIGN_RIGHT); Paragraph paragraph = new Paragraph(); paragraph.setFont(font); paragraph.add( "??"); paragraph.setAlignment(Element.ALIGN_CENTER); document.add(paragraph); creteEmptyLine(created, 1); }
From source file:com.planning.project.controller.CreatePDF.java
private static void createPagePDFBudwork(Document document, TbDescriptionstatement tbDescriptionstatement) throws DocumentException, IOException { Font font = new Font(BaseFont.createFont("D:/THSarabunNew.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED)); font.setSize(16);/*from ww w. j av a 2 s . c o m*/ Paragraph title = new Paragraph(); title.setFont(font); creteEmptyLine(title, 1); title.setFont(font); title.add(": " + tbDescriptionstatement.getTbBudget().getBudgetName()); creteEmptyLine(title, 1); title.add(": " + tbDescriptionstatement.getTbYear().getYearValue()); creteEmptyLine(title, 1); title.add(": " + tbDescriptionstatement.getTbFaculty().getFacultyName()); creteEmptyLine(title, 1); title.add( ": " + tbDescriptionstatement.getTbFaculty().getTbCampus().getCampusName()); creteEmptyLine(title, 1); title.add(" : " + tbDescriptionstatement.getTbProduct().getProductName()); creteEmptyLine(title, 1); title.add(": " + tbDescriptionstatement.getTbBudgetType().getBdTypeName()); creteEmptyLine(title, 1); title.add(": " + tbDescriptionstatement.getTotal() + " "); creteEmptyLine(title, 1); /* * title.add(": " + * tbDescriptionstatement.getAllocateMoney() + " "); * creteEmptyLine(title, 1); title.add(": " * + (Integer.parseInt(tbDescriptionstatement.getAllocateMoney()) - * Integer.parseInt(tbDescriptionstatement.getMoneyBalance())) + " " * ); creteEmptyLine(title, 1); title.add(": " + * tbDescriptionstatement.getMoneyBalance() + " "); * creteEmptyLine(title, 1); */ document.add(title); }
From source file:com.planning.project.controller.CreatePDF.java
private static void createHeadlistBudwork(Document document, String check) throws DocumentException, IOException { Font font = new Font(BaseFont.createFont("D:/THSarabunNew.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED)); font.setSize(18);/*from w w w .j av a2 s .c o m*/ Paragraph title = new Paragraph(); title.setFont(font); creteEmptyLine(title, 1); if (check == "1") { title.add("1. ?"); } else if (check == "2") { title.add("2. "); } else if (check == "3") { title.add("3. "); } else if (check == "4") { title.add("4. "); } creteLine(title, 1); creteEmptyLine(title, 1); document.add(title); }
From source file:com.planning.project.controller.CreatePDF.java
private static void addTitlePageBud(Document document) throws DocumentException, IOException { Font font = new Font(BaseFont.createFont("D:/THSarabunNew.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED)); font.setSize(24);// www . j a v a2 s . c o m String imagepath = "src/main/webapp/resources/images/logo.jpg"; Image img = Image.getInstance(imagepath); img.scaleToFit(70f, 70f); SimpleDateFormat simpleDateFormat = new SimpleDateFormat("MM/dd/yyyy"); Paragraph created = new Paragraph(); created.setFont(TIME_ROMAN_SMALL); created.add("Report created on " + simpleDateFormat.format(new Date())); created.setAlignment(Element.ALIGN_RIGHT); Paragraph logo = new Paragraph(); logo.setFont(TIME_ROMAN_SMALL); logo.add(img); logo.setAlignment(Element.ALIGN_LEFT); document.add(created); document.add(logo); // Paragraph created = new Paragraph(); // created.setFont(TIME_ROMAN_SMALL); // created.add("Report created on " + simpleDateFormat.format(new // Date())); // created.setAlignment(Element.ALIGN_RIGHT); Paragraph paragraph = new Paragraph(); paragraph.setFont(font); paragraph.add( "?"); paragraph.setAlignment(Element.ALIGN_CENTER); document.add(paragraph); creteEmptyLine(created, 1); }
From source file:com.prjhuellvotweb.controlador.PDF.java
protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { //Preguntar por la sesion del usuario admin HttpSession sessionOk = request.getSession(true); if (sessionOk.getAttribute("admin") != null) { //cambiar a tipo application/pdf response.setContentType("application/pdf;charset=UTF-8"); //flujo de salida OutputStream out = response.getOutputStream(); String texto = request.getParameter("report"); //texto = "Reporte de los proyectos Sena CTGI (Centro tecnologico de gestion industrial) donde se dan a conocer" // + " los nombres de los proyectos y cantidad de votos obtenidos para cada proyecto."; try {/*from w ww .jav a 2 s . com*/ Connection con = Conexion.conectar("mysql"); DAOVoto dao = new DAOVoto(); List<List> lista = dao.estadisticaNumeroVotos(); Voto t = dao.contarVotos(); int to = t.getIdUsuario(); if (!lista.isEmpty() && lista.size() > 0) { try { //programar pdf Document documento = new Document(); //asosciar documento con la salida PdfWriter.getInstance(documento, out);// salida del cocumento en pdf //abrir documento documento.open(); Paragraph par2 = new Paragraph(); Paragraph par4 = new Paragraph(); //agregar una imagen logo sena al pdf Image imagenes = Image .getInstance(getServletContext().getRealPath("") + "/Multimedia/reportes.png"); //Centrar la imagen imagenes.setAlignment(Element.ALIGN_CENTER); //tamao de la imagen imagenes.scaleToFit(530, 520); //agg imagen al documento F:\\Documentos\\yo\\huellvot 2 17-06-2016\\PrjHuellVotWeb\\web\\iCO.png //documento.add(imghuellvot); documento.add(imagenes); //Agg salto de linea par2.add(new Phrase(Chunk.NEWLINE)); par2.add(new Phrase(Chunk.NEWLINE)); //fuente del pdf, tipo de fuente famimilia tamao de letra //Importar ttf que contiene el tipo de letra FontFactory.register( "C:\\Users\\pc\\Desktop\\PrjHuellVotWeb\\web\\fonts\\roboto\\Roboto-Bold.ttf", "Roboto"); //Font fondescripcion = FontFactory.getFont("Roboto"); Font fondescripcion = new Font(Font.getFamily("Roboto"), 16, Font.NORMAL, BaseColor.BLACK); //texto de la descripcion par2.add(new Phrase(texto, fondescripcion)); //justificar descripcion par2.setAlignment(Element.ALIGN_JUSTIFIED); //Agg salto de linea par2.add(new Phrase(Chunk.NEWLINE)); par2.add(new Phrase(Chunk.NEWLINE)); //agregar descripcion al documento documento.add(par2);//agregar todas las propiedades de la descripcin //crear una tabla PdfPTable tabla = new PdfPTable(5);//( Numero de columnas de la tabla) //columnas de la tabla, cabezera y agg un estilo PdfPCell celda = new PdfPCell( new Paragraph("Nmero", FontFactory.getFont("Roboto", 14, Font.BOLD))); PdfPCell celda1 = new PdfPCell( new Paragraph("Nombre", FontFactory.getFont("Roboto", 14, Font.BOLD))); celda1.setColspan(3); PdfPCell celda2 = new PdfPCell( new Paragraph("Votos", FontFactory.getFont("Roboto", 14, Font.BOLD))); //Color de fondo celda.setBackgroundColor(new BaseColor(252, 115, 35)); celda1.setBackgroundColor(new BaseColor(252, 115, 35)); celda2.setBackgroundColor(new BaseColor(252, 115, 35)); //Centrar celda.setHorizontalAlignment(Element.ALIGN_CENTER); celda1.setHorizontalAlignment(Element.ALIGN_CENTER); celda2.setHorizontalAlignment(Element.ALIGN_CENTER); //padding celda.setPadding(8.0f); celda1.setPadding(8.0f); celda2.setPadding(8.0f); //agg columna ala tabla tabla.addCell(celda); tabla.addCell(celda1); tabla.addCell(celda2); for (int i = 0; i < lista.size(); i++) { List l = lista.get(i); //Convertir el entero a string String num = String.valueOf(l.get(0)); String nom = String.valueOf(l.get(1)); String tot = String.valueOf(l.get(2)); //Agregar valores a las celdas PdfPCell c = new PdfPCell( new Paragraph(num, FontFactory.getFont("Roboto", 12, Font.BOLD))); PdfPCell c1 = new PdfPCell( new Paragraph(nom, FontFactory.getFont("Roboto", 12, Font.BOLD))); c1.setColspan(3); PdfPCell c2 = new PdfPCell( new Paragraph(tot, FontFactory.getFont("Roboto", 12, Font.BOLD))); //Padding para las celdas c.setPadding(4.0f); c1.setPadding(4.0f); c2.setPadding(4.0f); //Centrar contenido de celda c.setHorizontalAlignment(Element.ALIGN_CENTER); c2.setHorizontalAlignment(Element.ALIGN_CENTER); //mostrar los resultados de cada columna los agrega a la tabla tabla.addCell(c); tabla.addCell(c1); tabla.addCell(c2); } PdfPCell c1 = new PdfPCell(new Paragraph("Total Votos: ", fondescripcion)); c1.setColspan(4); PdfPCell c2 = new PdfPCell(new Paragraph("" + to, fondescripcion)); c1.setHorizontalAlignment(Element.ALIGN_CENTER); c2.setHorizontalAlignment(Element.ALIGN_CENTER); c1.setPadding(4.0f); c2.setPadding(4.0f); tabla.addCell(c1); tabla.addCell(c2); //Agrega la tabla a el documento documento.add(tabla); //agregar fecha Font fonfecha = new Font(Font.getFamily("Roboto"), 12, Font.NORMAL, BaseColor.LIGHT_GRAY); par4.add(new Phrase("Expedido por HuellVot", fonfecha)); DateFormat formato = DateFormat.getDateInstance(DateFormat.FULL); par4.add(new Paragraph(formato.format(new Date()))); documento.add(par4); //cerrar el documento documento.close(); } catch (DocumentException | IOException e) { e.getMessage(); System.out.println("Error al generar el reporte PDF" + e); } } else { try { Document documento = new Document(); PdfWriter.getInstance(documento, out);// salida del cocumento en pdf //abrir documento documento.open(); System.out.println("no hat datos"); //agregar una imagen logo sena al pdf Image imagenes = Image.getInstance( "C:\\Users\\pc\\Desktop\\PrjHuellVotWeb\\web\\Multimedia\\reportes.png"); //Centrar la imagen imagenes.setAlignment(Element.ALIGN_CENTER); //tamao de la imagen imagenes.scaleToFit(530, 520); //agg imagen al documento F:\\Documentos\\yo\\huellvot 2 17-06-2016\\PrjHuellVotWeb\\web\\iCO.png //documento.add(imghuellvot); documento.add(imagenes); Paragraph par1 = new Paragraph(); Paragraph par2 = new Paragraph(); //Agg salto de linea par1.add(new Phrase(Chunk.NEWLINE)); par1.add(new Phrase(Chunk.NEWLINE)); //fuente del pdf, tipo de fuente famimilia tamao de letra //Importar ttf que contiene el tipo de letra FontFactory.register( "C:\\Users\\pc\\Desktop\\PrjHuellVotWeb\\web\\fonts\\roboto\\Roboto-Bold.ttf", "Roboto"); //Font fondescripcion = FontFactory.getFont("Roboto"); Font fondescripcion = new Font(Font.getFamily("Roboto"), 16, Font.NORMAL, BaseColor.BLACK); //texto de la descripcion par1.add(new Phrase("lo sentimos pero no hay datos para mostrar.!", fondescripcion)); //justificar descripcion par1.setAlignment(Element.ALIGN_CENTER); //Agg salto de linea par1.add(new Phrase(Chunk.NEWLINE)); par1.add(new Phrase(Chunk.NEWLINE)); //agregar descripcion al documento documento.add(par1);//agregar todas las propiedades de la descripcin //agregar fecha Font fonfecha = new Font(Font.getFamily("Roboto"), 12, Font.NORMAL, BaseColor.LIGHT_GRAY); par2.add(new Phrase("Expedido por HuellVot", fonfecha)); DateFormat formato = DateFormat.getDateInstance(DateFormat.FULL); par2.add(new Paragraph(formato.format(new Date()))); documento.add(par2); //cerrar el documento documento.close(); } catch (DocumentException ex) { ex.getMessage(); System.out.println("Error al generar el reporte PDF sin datos registrados" + ex); } } } finally { out.close(); } } else { sessionOk.invalidate(); response.sendRedirect("index.jsp"); } }
From source file:com.quix.aia.cn.imo.mapper.ApplicationFormPDFMaintenance.java
License:Open Source License
private static Document ESingnature(Document document, PdfWriter writer, AddressBook addressbook) { // TODO Auto-generated method stub log.log(Level.INFO, "ApplicationFormPDFMaintenance --> ESingnature "); try {/*w w w. j a va 2 s. co m*/ document.newPage(); PdfPTable table = new PdfPTable(2); table.setSpacingBefore(10); table.setWidthPercentage(100f); PdfPCell c1 = new PdfPCell(new Phrase("E-singnature ")); c1.setHorizontalAlignment(Element.ALIGN_LEFT); c1.setColspan(4); c1.setBorder(Rectangle.LEFT | Rectangle.RIGHT | Rectangle.TOP); c1.setFixedHeight(30f); c1.setBackgroundColor(BaseColor.LIGHT_GRAY); c1.setBorder(Rectangle.BOX); c1.setFixedHeight(25f); table.addCell(c1); table.setHeaderRows(1); for (int i = 0; i < 2; i++) { c1 = new PdfPCell(new Phrase(" ", font)); c1.setBorder(Rectangle.NO_BORDER); c1.setLeading(4f, 0f); c1.setFixedHeight(15f); table.addCell(c1); } Iterator itr = null; CandidateESignature esignature = new CandidateESignature(); if (addressbook.getCandidateESignatures().size() > 0) { itr = addressbook.getCandidateESignatures().iterator(); esignature = (CandidateESignature) itr.next(); } c1 = new PdfPCell(new Phrase("Branch : " + esignature.getBranch(), font)); c1.setBorder(Rectangle.NO_BORDER); c1.setLeading(4f, 0f); c1.setFixedHeight(15f); c1.setBorder(Rectangle.BOTTOM); table.addCell(c1); c1 = new PdfPCell(new Phrase("Servicing Department : " + esignature.getServiceDepartment(), font)); c1.setBorder(Rectangle.NO_BORDER); c1.setLeading(4f, 0f); c1.setFixedHeight(15f); c1.setBorder(Rectangle.BOTTOM); table.addCell(c1); for (int i = 0; i < 2; i++) { c1 = new PdfPCell(new Phrase(" ", font)); c1.setBorder(Rectangle.NO_BORDER); c1.setLeading(4f, 0f); c1.setFixedHeight(15f); table.addCell(c1); } c1 = new PdfPCell(new Phrase("City : " + esignature.getCity(), font)); c1.setBorder(Rectangle.NO_BORDER); c1.setLeading(4f, 0f); c1.setFixedHeight(15f); c1.setBorder(Rectangle.BOTTOM); table.addCell(c1); c1 = new PdfPCell(new Phrase("Agent Code : " + esignature.getAgentId(), font)); c1.setBorder(Rectangle.NO_BORDER); c1.setLeading(4f, 0f); c1.setFixedHeight(15f); c1.setBorder(Rectangle.BOTTOM); table.addCell(c1); for (int i = 0; i < 4; i++) { c1 = new PdfPCell(new Phrase(" ", font)); c1.setBorder(Rectangle.NO_BORDER); c1.setLeading(4f, 0f); c1.setFixedHeight(15f); table.addCell(c1); } document.add(table); table = new PdfPTable(2); table.setSpacingBefore(10); table.setWidthPercentage(100f); table.setWidths(new int[] { 80, 20 }); c1 = new PdfPCell(new Phrase("Presently attached with another insurance Company ? ", font)); c1.setBorder(Rectangle.NO_BORDER); c1.setLeading(4f, 0f); c1.setFixedHeight(15f); table.addCell(c1); c1 = new PdfPCell(new Phrase("Yes \t\t\t\t\t\t\t\t No", font)); c1.setBorder(Rectangle.NO_BORDER); c1.setLeading(4f, 0f); c1.setFixedHeight(15f); table.addCell(c1); for (int i = 0; i < 2; i++) { c1 = new PdfPCell(new Phrase(" ", font)); c1.setBorder(Rectangle.NO_BORDER); c1.setLeading(4f, 0f); c1.setFixedHeight(15f); table.addCell(c1); } c1 = new PdfPCell( new Phrase("Presently in contact with any other AIA'S servicing Department ? ", font)); c1.setBorder(Rectangle.NO_BORDER); c1.setLeading(4f, 0f); c1.setFixedHeight(15f); table.addCell(c1); c1 = new PdfPCell(new Phrase("Yes \t\t\t\t\t\t\t\t No", font)); c1.setBorder(Rectangle.NO_BORDER); c1.setLeading(4f, 0f); c1.setFixedHeight(15f); table.addCell(c1); for (int i = 0; i < 2; i++) { c1 = new PdfPCell(new Phrase(" ", font)); c1.setBorder(Rectangle.NO_BORDER); c1.setLeading(4f, 0f); c1.setFixedHeight(15f); table.addCell(c1); } c1 = new PdfPCell( new Phrase("Taken LOMBRA occupational test or PSP test in the past ? If Yes, ", font)); c1.setBorder(Rectangle.NO_BORDER); c1.setLeading(4f, 0f); c1.setFixedHeight(15f); table.addCell(c1); c1 = new PdfPCell(new Phrase("Yes \t\t\t\t\t\t\t\t No", font)); c1.setBorder(Rectangle.NO_BORDER); c1.setLeading(4f, 0f); c1.setFixedHeight(15f); table.addCell(c1); for (int i = 0; i < 2; i++) { c1 = new PdfPCell(new Phrase(" ", font)); c1.setBorder(Rectangle.NO_BORDER); c1.setLeading(4f, 0f); c1.setFixedHeight(15f); table.addCell(c1); } c1 = new PdfPCell(new Phrase("Please provide the result. ", font)); c1.setBorder(Rectangle.NO_BORDER); c1.setLeading(4f, 0f); c1.setFixedHeight(15f); table.addCell(c1); for (int i = 0; i < 5; i++) { c1 = new PdfPCell(new Phrase(" ", font)); c1.setBorder(Rectangle.NO_BORDER); c1.setLeading(4f, 0f); c1.setFixedHeight(15f); table.addCell(c1); } document.add(table); Paragraph para1 = new Paragraph(); para1.add(new Chunk("Applicant's Declaration ", font)); para1.setAlignment(Element.ALIGN_LEFT); para1.setSpacingAfter(5f); document.add(para1); table = new PdfPTable(2); table.setSpacingBefore(10); table.setWidthPercentage(100f); for (int i = 0; i < 4; i++) { c1 = new PdfPCell(new Phrase(" ", font)); c1.setBorder(Rectangle.NO_BORDER); c1.setLeading(4f, 0f); c1.setFixedHeight(15f); table.addCell(c1); c1 = new PdfPCell(new Phrase(" ", font)); c1.setBorder(Rectangle.NO_BORDER); c1.setLeading(4f, 0f); c1.setFixedHeight(15f); table.addCell(c1); } c1 = new PdfPCell(new Phrase("Application Date", font)); c1.setBorder(Rectangle.NO_BORDER); c1.setLeading(4f, 0f); c1.setFixedHeight(15f); table.addCell(c1); c1 = new PdfPCell(new Phrase("Applicant/Candidate Name :", font)); c1.setBorder(Rectangle.NO_BORDER); c1.setLeading(4f, 0f); c1.setFixedHeight(15f); table.addCell(c1); if (esignature.getApplicationDate() != null) { c1 = new PdfPCell(new Phrase(format.format(esignature.getApplicationDate()), font)); c1.setBorder(Rectangle.NO_BORDER); c1.setLeading(4f, 0f); c1.setFixedHeight(15f); table.addCell(c1); } else { c1 = new PdfPCell(new Phrase("", font)); c1.setBorder(Rectangle.NO_BORDER); c1.setLeading(4f, 0f); c1.setFixedHeight(15f); table.addCell(c1); } c1 = new PdfPCell(new Phrase(esignature.getCandidateName(), font)); c1.setBorder(Rectangle.NO_BORDER); c1.setLeading(4f, 0f); c1.setFixedHeight(15f); table.addCell(c1); for (int i = 0; i < 4; i++) { c1 = new PdfPCell(new Phrase(" ", font)); c1.setBorder(Rectangle.NO_BORDER); c1.setLeading(4f, 0f); c1.setFixedHeight(15f); table.addCell(c1); c1 = new PdfPCell(new Phrase(" ", font)); c1.setBorder(Rectangle.NO_BORDER); c1.setLeading(4f, 0f); c1.setFixedHeight(15f); table.addCell(c1); } document.add(table); para1 = new Paragraph(); para1.add(new Chunk("E-Signature : ", font)); para1.setAlignment(Element.ALIGN_LEFT); para1.setSpacingAfter(5f); document.add(para1); c1 = new PdfPCell(new Phrase(" ", font)); c1.setBorder(Rectangle.NO_BORDER); c1.setLeading(4f, 0f); c1.setFixedHeight(15f); table.addCell(c1); if (esignature.geteSignaturePhoto() != null) { Image image = Image.getInstance(esignature.geteSignaturePhoto()); para1 = new Paragraph(); para1.add(image); para1.setAlignment(Element.ALIGN_LEFT); para1.setSpacingAfter(5f); document.add(para1); } else { para1 = new Paragraph(); para1.add(""); para1.setAlignment(Element.ALIGN_LEFT); para1.setSpacingAfter(5f); document.add(para1); } } catch (Exception e) { // TODO Auto-generated catch block log.log(Level.INFO, "ApplicationFormPDFMaintenance --> ESingnature " + e.getMessage()); e.printStackTrace(); e.printStackTrace(); LogsMaintenance logsMain = new LogsMaintenance(); StringWriter errors = new StringWriter(); e.printStackTrace(new PrintWriter(errors)); logsMain.insertLogs("ApplicationFormPDFMaintenance", Level.SEVERE + "", errors.toString()); } return document; }