List of usage examples for com.itextpdf.text Document add
public boolean add(Element element) throws DocumentException
Element
to the Document
. From source file:com.primeleaf.krystal.web.action.console.OpenDocumentClassAction.java
License:Open Source License
private File generatePdfFile(ArrayList<Hit> hits, ArrayList<IndexDefinition> indexes, User loggedInUser) throws Exception { File tempPdf = File.createTempFile("tempPdf", ".pdf"); FileOutputStream file = new FileOutputStream(tempPdf); Document document = new Document(PageSize.A3.rotate()); PdfWriter.getInstance(document, file); document.open();/*from w ww . j av a2 s . c om*/ Font boldFont12 = new Font(FontFamily.HELVETICA, 12, Font.BOLD); Font normalFont10 = new Font(FontFamily.HELVETICA, 10, Font.NORMAL); int colCount = 9; //predefined columns count int colSize = indexes.size() + colCount; float[] columnWidths = new float[colSize]; for (int i = 0; i < columnWidths.length; i++) { columnWidths[i] = (100 / colSize); } PdfPTable table = new PdfPTable(columnWidths); table.setWidthPercentage(100f); if (hits.size() > 0) { BaseColor bgColor = new BaseColor(225, 240, 255); insertCellPDF(table, "Document ID", Element.ALIGN_CENTER, 1, boldFont12, bgColor); insertCellPDF(table, "Revision ID", Element.ALIGN_CENTER, 1, boldFont12, bgColor); insertCellPDF(table, "Created By", Element.ALIGN_CENTER, 1, boldFont12, bgColor); insertCellPDF(table, "Last Modified By", Element.ALIGN_CENTER, 1, boldFont12, bgColor); insertCellPDF(table, "File Size", Element.ALIGN_CENTER, 1, boldFont12, bgColor); insertCellPDF(table, "Created On", Element.ALIGN_CENTER, 1, boldFont12, bgColor); insertCellPDF(table, "Last Modified On", Element.ALIGN_CENTER, 1, boldFont12, bgColor); insertCellPDF(table, "Expiry On", Element.ALIGN_CENTER, 1, boldFont12, bgColor); for (IndexDefinition index : indexes) { insertCellPDF(table, index.getIndexDisplayName(), Element.ALIGN_CENTER, 1, boldFont12, bgColor); } insertCellPDF(table, "Note", Element.ALIGN_CENTER, 1, boldFont12, bgColor); int count = 0; for (Hit hit : hits) { count++; if (count % 2 == 0) { bgColor = new BaseColor(240, 240, 240); } else { bgColor = new BaseColor(210, 210, 210); } insertCellPDF(table, hit.documentId + "", Element.ALIGN_CENTER, 1, normalFont10, bgColor); insertCellPDF(table, hit.revisionId, Element.ALIGN_CENTER, 1, normalFont10, bgColor); insertCellPDF(table, hit.createdBy, Element.ALIGN_CENTER, 1, normalFont10, bgColor); insertCellPDF(table, hit.modifiedBy + "", Element.ALIGN_CENTER, 1, normalFont10, bgColor); insertCellPDF(table, StringHelper.formatSizeText(hit.fileLength), Element.ALIGN_CENTER, 1, normalFont10, bgColor); insertCellPDF(table, hit.created, Element.ALIGN_CENTER, 1, normalFont10, bgColor); insertCellPDF(table, hit.modified, Element.ALIGN_CENTER, 1, normalFont10, bgColor); insertCellPDF(table, hit.expiryOn, Element.ALIGN_CENTER, 1, normalFont10, bgColor); for (String index : hit.indexValues) { insertCellPDF(table, index, Element.ALIGN_LEFT, 1, normalFont10, bgColor); } ArrayList<DocumentNote> documentNotes = DocumentNoteDAO.getInstance() .readJournalNotes("DOCUMENTID=" + hit.documentId + " AND ACTIVE ='Y' ORDER BY 1 DESC"); String notesData = ""; if (documentNotes.size() > 0) { for (DocumentNote documentNote : documentNotes) { if (!"P".equalsIgnoreCase(documentNote.getNoteType())) { if (!loggedInUser.getUserName().equalsIgnoreCase(documentNote.getUserName())) { continue; } } User user = UserDAO.getInstance().readUserByName(documentNote.getUserName()); notesData += documentNote.getNoteData() + "\n"; notesData += "Posted By" + " : " + user.getRealName() + "\n"; notesData += "Posted On" + " : " + StringHelper.formatDate(documentNote.getCreated()); notesData += "\n"; } } insertCellPDF(table, notesData, Element.ALIGN_LEFT, 1, normalFont10, bgColor); } } try { document.add(table); document.close(); file.close(); } catch (Exception e) { e.printStackTrace(); } return tempPdf; }
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 ww w .j av a 2 s. c o m 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.propelics.pdfcreator.PdfcreatorModule.java
License:Open Source License
private void generateiTextPDFfunction(HashMap args) { Log.d(PROXY_NAME, "generateiTextPDFfunction()"); String filename = ""; TiUIView webview = null;/*from www .ja v a 2 s . co m*/ int quality = 100; try { if (args.containsKey("filename")) { filename = (String) args.get("filename"); Log.d(PROXY_NAME, "filename: " + filename); } else return; if (args.containsKey("webview")) { TiViewProxy viewProxy = (TiViewProxy) args.get("webview"); webview = viewProxy.getOrCreateView(); Log.d(PROXY_NAME, "webview: " + webview.toString()); } else return; if (args.containsKey("quality")) { quality = TiConvert.toInt(args.get("quality")); } TiBaseFile file = TiFileFactory.createTitaniumFile(filename, true); Log.d(PROXY_NAME, "file full path: " + file.nativePath()); OutputStream outputStream = file.getOutputStream(); final int MARGIN = 0; final float PDF_WIDTH = PageSize.LETTER.getWidth() - MARGIN * 2; // A4: 595 //Letter: 612 final float PDF_HEIGHT = PageSize.LETTER.getHeight() - MARGIN * 2; // A4: 842 //Letter: 792 final int DEFAULT_VIEW_WIDTH = 980; final int DEFAULT_VIEW_HEIGHT = 1384; int viewWidth = DEFAULT_VIEW_WIDTH; int viewHeight = DEFAULT_VIEW_HEIGHT; Document pdfDocument = new Document(PageSize.LETTER, MARGIN, MARGIN, MARGIN, MARGIN); PdfWriter docWriter = PdfWriter.getInstance(pdfDocument, outputStream); Log.d(PROXY_NAME, "PDF_WIDTH: " + PDF_WIDTH); Log.d(PROXY_NAME, "PDF_HEIGHT: " + PDF_HEIGHT); WebView view = (WebView) webview.getNativeView(); if (TiApplication.isUIThread()) { viewWidth = view.capturePicture().getWidth(); viewHeight = view.capturePicture().getHeight(); if (viewWidth <= 0) { viewWidth = DEFAULT_VIEW_WIDTH; } if (viewHeight <= 0) { viewHeight = DEFAULT_VIEW_HEIGHT; } } else { Log.e(PROXY_NAME, "NO UI THREAD"); viewWidth = DEFAULT_VIEW_WIDTH; viewHeight = DEFAULT_VIEW_HEIGHT; } view.setLayerType(View.LAYER_TYPE_SOFTWARE, null); Log.d(PROXY_NAME, "viewWidth: " + viewWidth); Log.d(PROXY_NAME, "viewHeight: " + viewHeight); float scaleFactorWidth = 1 / (viewWidth / PDF_WIDTH); float scaleFactorHeight = 1 / (viewHeight / PDF_HEIGHT); Log.d(PROXY_NAME, "scaleFactorWidth: " + scaleFactorWidth); Log.d(PROXY_NAME, "scaleFactorHeight: " + scaleFactorHeight); Bitmap viewBitmap = Bitmap.createBitmap(viewWidth, viewHeight, Bitmap.Config.ARGB_8888); Canvas viewCanvas = new Canvas(viewBitmap); // Paint paintAntialias = new Paint(); // paintAntialias.setAntiAlias(true); // paintAntialias.setFilterBitmap(true); Drawable bgDrawable = view.getBackground(); if (bgDrawable != null) { bgDrawable.draw(viewCanvas); } else { viewCanvas.drawColor(Color.WHITE); } view.draw(viewCanvas); TiBaseFile pdfImg = createTempFile(filename); viewBitmap.compress(Bitmap.CompressFormat.PNG, quality, pdfImg.getOutputStream()); FileInputStream pdfImgInputStream = new FileInputStream(pdfImg.getNativeFile()); byte[] pdfImgBytes = IOUtils.toByteArray(pdfImgInputStream); pdfImgInputStream.close(); pdfDocument.open(); float yFactor = viewHeight * scaleFactorWidth; int pageNumber = 1; do { if (pageNumber > 1) { pdfDocument.newPage(); } pageNumber++; yFactor -= PDF_HEIGHT; Image pageImage = Image.getInstance(pdfImgBytes, true); // Image pageImage = Image.getInstance(buffer.array()); pageImage.scalePercent(scaleFactorWidth * 100); pageImage.setAbsolutePosition(0f, -yFactor); pdfDocument.add(pageImage); Log.d(PROXY_NAME, "yFactor: " + yFactor); } while (yFactor > 0); pdfDocument.close(); sendCompleteEvent(filename); } catch (Exception exception) { sendErrorEvent(exception); } }
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 {/*from www . j a v a 2 s. c o 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; }
From source file:com.quix.aia.cn.imo.mapper.ApplicationFormPDFMaintenance.java
License:Open Source License
private static Document personalCertification(Document document, PdfWriter writer, AddressBook addressbook) { // TODO Auto-generated method stub log.log(Level.INFO, "ApplicationFormPDFMaintenance --> personalCertification "); try {/* ww w . j a v a 2 s . co m*/ /* New Page */ document.newPage(); PdfPTable table = new PdfPTable(2); table.setSpacingBefore(10); table.setWidthPercentage(100f); int i = 0; for (Iterator itr = addressbook.getCandidateProfessionalCertifications().iterator(); itr.hasNext();) { CandidateProfessionalCertification procertification = (CandidateProfessionalCertification) itr .next(); if (i != 0) { PdfPCell 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); } i++; PdfPCell c1 = new PdfPCell(new Phrase("PERSONAL CERTIFICATION")); 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 j = 0; j < 2; j++) { 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("Certificate Name: " + procertification.getCertificateName(), 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("Chrater Agency: " + procertification.getCharterAgency(), font)); c1.setBorder(Rectangle.NO_BORDER); c1.setLeading(4f, 0f); c1.setFixedHeight(15f); c1.setBorder(Rectangle.BOTTOM); table.addCell(c1); for (int j = 0; j < 2; j++) { 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("Charter Date : " + format.format(procertification.getCharterDate()), 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(" ", font)); c1.setBorder(Rectangle.NO_BORDER); c1.setLeading(4f, 0f); c1.setFixedHeight(15f); //c1.setBorder(Rectangle.BOTTOM); table.addCell(c1); } document.add(table); } catch (Exception e) { // TODO Auto-generated catch block log.log(Level.INFO, "ApplicationFormPDFMaintenance --> personalCertification " + 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; }
From source file:com.quix.aia.cn.imo.mapper.ApplicationFormPDFMaintenance.java
License:Open Source License
private static Document Education(Document document, PdfWriter writer, AddressBook addressbook) { // TODO Auto-generated method stub log.log(Level.INFO, "ApplicationFormPDFMaintenance --> Education "); try {/*from w w w. j av a2 s .c o m*/ /* New Page */ document.newPage(); PdfPTable table = new PdfPTable(2); table.setSpacingBefore(10); table.setWidthPercentage(100f); int i = 0; for (Iterator itr = addressbook.getCandidateEducations().iterator(); itr.hasNext();) { CandidateEducation candidateEducation = (CandidateEducation) itr.next(); if (i != 0) { PdfPCell 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); } i++; PdfPCell c1 = new PdfPCell(new Phrase("EDUCATION")); 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 j = 0; j < 2; j++) { 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("Start Date: " + format.format(candidateEducation.getStartDate()), 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("End Date: " + format.format(candidateEducation.getEndDate()), font)); c1.setBorder(Rectangle.NO_BORDER); c1.setLeading(4f, 0f); c1.setFixedHeight(15f); c1.setBorder(Rectangle.BOTTOM); table.addCell(c1); for (int j = 0; j < 2; j++) { 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("Witness : " + candidateEducation.getWitness(), 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("Education : " + candidateEducation.getEducation(), font)); c1.setBorder(Rectangle.NO_BORDER); c1.setLeading(4f, 0f); c1.setFixedHeight(15f); c1.setBorder(Rectangle.BOTTOM); table.addCell(c1); for (int j = 0; j < 2; j++) { 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("Education Level : " + candidateEducation.getEducationLevel(), 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("School : " + candidateEducation.getSchool(), font)); c1.setBorder(Rectangle.NO_BORDER); c1.setLeading(4f, 0f); c1.setFixedHeight(15f); c1.setBorder(Rectangle.BOTTOM); table.addCell(c1); for (int j = 0; j < 2; j++) { 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("Witness Contect Number : " + candidateEducation.getWitnessContactNo(), 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(" ", font)); c1.setBorder(Rectangle.NO_BORDER); c1.setLeading(4f, 0f); c1.setFixedHeight(15f); //c1.setBorder(Rectangle.BOTTOM); table.addCell(c1); } document.add(table); } catch (Exception e) { // TODO Auto-generated catch block log.log(Level.INFO, "ApplicationFormPDFMaintenance --> Education " + 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; }
From source file:com.quix.aia.cn.imo.mapper.ApplicationFormPDFMaintenance.java
License:Open Source License
private static Document workExperience(Document document, PdfWriter writer, AddressBook addressbook) { // TODO Auto-generated method stub log.log(Level.INFO, "ApplicationFormPDFMaintenance --> workExperience "); try {// ww w. ja va 2s . co m document.newPage(); PdfPTable table = new PdfPTable(3); table.setSpacingBefore(10); table.setWidthPercentage(100f); int i = 0; for (Iterator itr = addressbook.getCandidateWorkExperiences().iterator(); itr.hasNext();) { CandidateWorkExperience candidateWorkExp = (CandidateWorkExperience) itr.next(); if (i != 0) { PdfPCell 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(" ", font)); c1.setBorder(Rectangle.NO_BORDER); c1.setLeading(4f, 0f); c1.setFixedHeight(15f); table.addCell(c1); } i++; PdfPCell c1 = new PdfPCell(new Phrase("WORK EXPERIENCE")); 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 j = 0; j < 3; j++) { 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("Start Date: " + format.format(candidateWorkExp.getStartDate()), 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("End Date: " + format.format(candidateWorkExp.getEndDate()), 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("Witness: " + candidateWorkExp.getWitness(), font)); c1.setBorder(Rectangle.NO_BORDER); c1.setLeading(4f, 0f); c1.setFixedHeight(15f); c1.setBorder(Rectangle.BOTTOM); table.addCell(c1); for (int j = 0; j < 3; j++) { 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("Unit : " + candidateWorkExp.getUnit(), 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("Occupation : " + candidateWorkExp.getOccupation(), 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("Witness Contect Number : \n\n\n \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t" + candidateWorkExp.getWitnessContactNo(), font)); c1.setBorder(Rectangle.NO_BORDER); c1.setLeading(4f, 0f); c1.setFixedHeight(25f); //c1.setPaddingBottom(10f); c1.setBorder(Rectangle.BOTTOM); table.addCell(c1); for (int j = 0; j < 3; j++) { 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("Income : " + candidateWorkExp.getIncome(), 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("Possition : " + candidateWorkExp.getPosition(), 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(" ", font)); c1.setBorder(Rectangle.NO_BORDER); c1.setLeading(4f, 0f); c1.setFixedHeight(15f); c1.setBorder(Rectangle.BOTTOM); table.addCell(c1); } document.add(table); } catch (Exception e) { // TODO Auto-generated catch block log.log(Level.INFO, "ApplicationFormPDFMaintenance --> workExperience " + 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; }
From source file:com.quix.aia.cn.imo.mapper.ApplicationFormPDFMaintenance.java
License:Open Source License
private static Document familyInformation(Document document, PdfWriter writer, AddressBook addressbook) { // TODO Auto-generated method stub log.log(Level.INFO, "ApplicationFormPDFMaintenance --> familyInformation "); try {// w w w . j a v a 2 s . c o m /* New Page */ document.newPage(); PdfPTable table = new PdfPTable(3); table.setSpacingBefore(10); table.setWidthPercentage(100f); //Set familylist=addressbook.getCandidateFamilyInfos(); int i = 0; for (Iterator itr = addressbook.getCandidateFamilyInfos().iterator(); itr.hasNext();) { CandidateFamilyInfo candidateFamilyInfo = (CandidateFamilyInfo) itr.next(); if (i != 0) { PdfPCell 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(" ", font)); c1.setBorder(Rectangle.NO_BORDER); c1.setLeading(4f, 0f); c1.setFixedHeight(15f); table.addCell(c1); } i++; PdfPCell c1 = new PdfPCell(new Phrase("FAMILY INFORMATION")); 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 j = 0; j < 3; j++) { 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("Name: " + candidateFamilyInfo.getName(), 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("Unit: " + candidateFamilyInfo.getUnit(), 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("Possition: " + candidateFamilyInfo.getPosition(), font)); c1.setBorder(Rectangle.NO_BORDER); c1.setLeading(4f, 0f); c1.setFixedHeight(15f); c1.setBorder(Rectangle.BOTTOM); table.addCell(c1); for (int j = 0; j < 3; j++) { 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("Relationship : " + candidateFamilyInfo.getRelationship(), 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("Occupation : " + candidateFamilyInfo.getOccupation(), 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("Phone : " + candidateFamilyInfo.getPhoneNo(), font)); c1.setBorder(Rectangle.NO_BORDER); c1.setLeading(4f, 0f); c1.setFixedHeight(15f); c1.setBorder(Rectangle.BOTTOM); table.addCell(c1); } document.add(table); } catch (Exception e) { // TODO Auto-generated catch block log.log(Level.INFO, "ApplicationFormPDFMaintenance --> familyInformation " + 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; }
From source file:com.quix.aia.cn.imo.mapper.ApplicationFormPDFMaintenance.java
License:Open Source License
private static Document personalInformation(Document document, PdfWriter writer, AddressBook addressbook, Font normalFontCH) {/*from w ww .ja va 2s .c o m*/ // TODO Auto-generated method stub log.log(Level.INFO, "ApplicationFormPDFMaintenance --> personalInformation "); try { PdfPTable table = new PdfPTable(2); table.setSpacingBefore(10); table.setWidthPercentage(100f); PdfPCell c1 = new PdfPCell(new Phrase("PERSONAL INFORMATION")); 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 j = 0; j < 2; j++) { 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("Candidate's Name: " + addressbook.getName(), font)); c1.setBorder(Rectangle.NO_BORDER); c1.setLeading(4f, 0f); c1.setFixedHeight(15f); //c1.setPaddingLeft(30f); c1.setBorder(Rectangle.NO_BORDER); table.addCell(c1); c1 = new PdfPCell(new Phrase("NRIC: " + addressbook.getNric(), font)); c1.setFixedHeight(15f); c1.setBorder(Rectangle.NO_BORDER); c1.setLeading(4f, 0f); table.addCell(c1); c1 = new PdfPCell(new Phrase("??* ", normalFontCH)); c1.setBorder(Rectangle.NO_BORDER); c1.setLeading(4f, 0f); c1.setFixedHeight(15f); c1.setBorder(Rectangle.BOTTOM); table.addCell(c1); c1 = new PdfPCell(new Phrase("???(*) ", normalFontCH)); c1.setBorder(Rectangle.NO_BORDER); c1.setLeading(4f, 0f); c1.setFixedHeight(15f); c1.setBorder(Rectangle.BOTTOM); table.addCell(c1); for (int j = 0; j < 2; j++) { 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("Date of Birth: " + format.format(addressbook.getBirthDate()), font)); c1.setBorder(Rectangle.NO_BORDER); c1.setLeading(4f, 0f); c1.setFixedHeight(15f); //c1.setPaddingLeft(30f); c1.setBorder(Rectangle.NO_BORDER); table.addCell(c1); c1 = new PdfPCell(new Phrase("Gender: " + addressbook.getGender(), font)); c1.setFixedHeight(15f); c1.setBorder(Rectangle.NO_BORDER); c1.setLeading(4f, 0f); table.addCell(c1); c1 = new PdfPCell(new Phrase("*", normalFontCH)); c1.setBorder(Rectangle.NO_BORDER); c1.setLeading(4f, 0f); c1.setFixedHeight(15f); c1.setBorder(Rectangle.BOTTOM); table.addCell(c1); c1 = new PdfPCell(new Phrase("*", normalFontCH)); c1.setBorder(Rectangle.NO_BORDER); c1.setLeading(4f, 0f); c1.setFixedHeight(15f); c1.setBorder(Rectangle.BOTTOM); table.addCell(c1); for (int j = 0; j < 2; j++) { 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("Age: " + addressbook.getAge(), font)); c1.setBorder(Rectangle.NO_BORDER); c1.setLeading(4f, 0f); c1.setFixedHeight(15f); //c1.setPaddingLeft(30f); c1.setBorder(Rectangle.NO_BORDER); table.addCell(c1); c1 = new PdfPCell(new Phrase("Place of Birth: " + addressbook.getBirthPlace(), font)); c1.setFixedHeight(15f); c1.setBorder(Rectangle.NO_BORDER); c1.setLeading(4f, 0f); table.addCell(c1); c1 = new PdfPCell(new Phrase("(*)", normalFontCH)); c1.setLeading(4f, 0f); c1.setFixedHeight(15f); c1.setBorder(Rectangle.BOTTOM); table.addCell(c1); c1 = new PdfPCell(new Phrase("", normalFontCH)); c1.setLeading(4f, 0f); c1.setFixedHeight(15f); c1.setBorder(Rectangle.BOTTOM); table.addCell(c1); for (int j = 0; j < 2; j++) { 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("Education: " + addressbook.getEducation(), font)); c1.setBorder(Rectangle.NO_BORDER); c1.setLeading(4f, 0f); c1.setFixedHeight(15f); //c1.setPaddingLeft(30f); c1.setBorder(Rectangle.NO_BORDER); table.addCell(c1); c1 = new PdfPCell(new Phrase("Maritial Status: " + addressbook.getMarritalStatus(), font)); c1.setFixedHeight(15f); c1.setBorder(Rectangle.NO_BORDER); c1.setLeading(4f, 0f); table.addCell(c1); c1 = new PdfPCell(new Phrase("*", normalFontCH)); c1.setLeading(4f, 0f); c1.setFixedHeight(15f); c1.setBorder(Rectangle.BOTTOM); table.addCell(c1); c1 = new PdfPCell(new Phrase("*", normalFontCH)); c1.setLeading(4f, 0f); c1.setFixedHeight(15f); c1.setBorder(Rectangle.BOTTOM); table.addCell(c1); for (int j = 0; j < 2; j++) { 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("Annual Income: " + addressbook.getYearlyIncome(), font)); c1.setBorder(Rectangle.NO_BORDER); c1.setLeading(4f, 0f); c1.setFixedHeight(15f); //c1.setPaddingLeft(30f); c1.setBorder(Rectangle.NO_BORDER); table.addCell(c1); c1 = new PdfPCell(new Phrase("Work Experience: " + addressbook.getWorkingYearExperience(), font)); c1.setFixedHeight(15f); c1.setBorder(Rectangle.NO_BORDER); c1.setLeading(4f, 0f); table.addCell(c1); c1 = new PdfPCell(new Phrase("*", normalFontCH)); c1.setLeading(4f, 0f); c1.setFixedHeight(15f); c1.setBorder(Rectangle.BOTTOM); table.addCell(c1); c1 = new PdfPCell(new Phrase("*", normalFontCH)); c1.setLeading(4f, 0f); c1.setFixedHeight(15f); c1.setBorder(Rectangle.BOTTOM); table.addCell(c1); for (int j = 0; j < 2; j++) { 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( "Address : " + addressbook.getResidentialAddress1() + " ," + addressbook.getResidentialAddress2() + " , " + addressbook.getResidentialAddress3(), font)); c1.setBorder(Rectangle.NO_BORDER); c1.setLeading(4f, 0f); c1.setFixedHeight(15f); //c1.setPaddingLeft(30f); c1.setBorder(Rectangle.NO_BORDER); 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("??*", normalFontCH)); c1.setLeading(4f, 0f); c1.setFixedHeight(15f); c1.setBorder(Rectangle.BOTTOM); table.addCell(c1); c1 = new PdfPCell(new Phrase(" ", normalFontCH)); c1.setLeading(4f, 0f); c1.setFixedHeight(15f); c1.setBorder(Rectangle.BOTTOM); table.addCell(c1); for (int j = 0; j < 2; j++) { 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("Postal Code: " + addressbook.getResidentialPostalCode(), font)); c1.setBorder(Rectangle.NO_BORDER); c1.setLeading(4f, 0f); c1.setFixedHeight(15f); //c1.setPaddingLeft(30f); c1.setBorder(Rectangle.NO_BORDER); table.addCell(c1); c1 = new PdfPCell(new Phrase("Mobile Number: " + addressbook.getMobilePhoneNo(), font)); c1.setFixedHeight(15f); c1.setBorder(Rectangle.NO_BORDER); c1.setLeading(4f, 0f); table.addCell(c1); c1 = new PdfPCell(new Phrase("??*", normalFontCH)); c1.setLeading(4f, 0f); c1.setFixedHeight(15f); c1.setBorder(Rectangle.BOTTOM); table.addCell(c1); c1 = new PdfPCell(new Phrase(" ", normalFontCH)); c1.setLeading(4f, 0f); c1.setFixedHeight(15f); c1.setBorder(Rectangle.BOTTOM); table.addCell(c1); for (int j = 0; j < 2; j++) { 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("Email Address: " + addressbook.geteMailId(), font)); c1.setBorder(Rectangle.NO_BORDER); c1.setLeading(4f, 0f); c1.setFixedHeight(15f); //c1.setPaddingLeft(30f); c1.setBorder(Rectangle.BOTTOM); table.addCell(c1); c1 = new PdfPCell(new Phrase(" ", font)); c1.setFixedHeight(15f); c1.setBorder(Rectangle.BOTTOM); c1.setLeading(4f, 0f); table.addCell(c1); document.add(table); } catch (Exception e) { // TODO Auto-generated catch block log.log(Level.INFO, "ApplicationFormPDFMaintenance --> personalInformation " + 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; }
From source file:com.quix.aia.cn.imo.mapper.ApplicationFormPDFMaintenance.java
License:Open Source License
private static void addTitle(Document document, PdfWriter writer, String fieldName, String headerText) throws Exception, IOException, BadElementException { log.log(Level.INFO, "ApplicationFormPDFMaintenance --> addTitle "); PdfPTable table = new PdfPTable(2); PdfPCell c1 = new PdfPCell(new Phrase(headerText)); c1.setHorizontalAlignment(Element.ALIGN_CENTER); c1.setVerticalAlignment(Element.ALIGN_CENTER); //c1.setBackgroundColor(BaseColor.RED); c1.setBorder(Rectangle.BOX);//from w w w. j a v a2 s. co m c1.setFixedHeight(25f); c1.setColspan(2); table.addCell(c1); table.setWidthPercentage(100f); document.add(table); }