List of usage examples for com.itextpdf.text Paragraph setAlignment
public void setAlignment(int alignment)
From source file:utils.pdf.cv_templates.Template3.java
private void addLanguages(List<Language> languages) throws DocumentException, IOException { Paragraph paragraph1, paragraph2; PdfPCell cell1, cell2, cell3;/*from w ww .j a v a2 s .co m*/ PdfPTable table1, table2, table3; // TABLE 1 table1 = new PdfPTable(new float[] { 5 }); table1.setWidthPercentage(100); cell1 = new PdfPCell(); cell1.setBorder(PdfPCell.NO_BORDER); cell1.setPaddingRight(15); cell1.setPaddingLeft(50); cell1.setPaddingTop(15); paragraph1 = new Paragraph("Idiomas", font1); paragraph1.setAlignment(paragraph1.ALIGN_LEFT); cell1.addElement(paragraph1); table1.addCell(cell1); document.add(table1); // TABLE 2 table2 = new PdfPTable(new float[] { 9, 1 }); table2.setWidthPercentage(100); // First column cell2 = new PdfPCell(); cell2.setBorder(PdfPCell.NO_BORDER); cell2.setPaddingTop(5); Image long_line_img = Image.getInstance(LONG_LINE_IMAGE); long_line_img.setBorderWidth(10); long_line_img.setBorderColor(BaseColor.WHITE); long_line_img.scaleToFit(475, 50); cell2.addElement(long_line_img); table2.addCell(cell2); // Second column cell2 = new PdfPCell(); cell2.setBorder(PdfPCell.NO_BORDER); table2.addCell(cell2); document.add(table2); //TABLE 3 for (int i = 0; i < languages.size(); i++) { table3 = new PdfPTable(new float[] { 6 }); table3.setWidthPercentage(100); table3.setSpacingBefore(5); //First column cell3 = new PdfPCell(); cell3.setBorder(PdfPCell.NO_BORDER); cell3.setPaddingRight(15); cell3.setPaddingLeft(50); if (i == 0) { cell3.setPaddingTop(-1); } paragraph2 = new Paragraph(languages.get(i).language + ". " + languages.get(i).level + ".", font3); paragraph2.setSpacingBefore(10); cell3.addElement(paragraph2); table3.addCell(cell3); document.add(table3); } }
From source file:utils.pdf.cv_templates.Template3.java
private void addSkills(User user, List<String> personalCharacteristics, List<Skill> skills) throws DocumentException, IOException { Paragraph paragraph1, paragraph2; PdfPCell cell1, cell2, cell3;/*from ww w .j a v a2s. c om*/ PdfPTable table1, table2, table3; // TABLE 1 table1 = new PdfPTable(new float[] { 5 }); table1.setWidthPercentage(100); cell1 = new PdfPCell(); cell1.setBorder(PdfPCell.NO_BORDER); cell1.setPaddingRight(15); cell1.setPaddingLeft(50); cell1.setPaddingTop(15); paragraph1 = new Paragraph("Cualidades", font1); paragraph1.setAlignment(paragraph1.ALIGN_LEFT); cell1.addElement(paragraph1); table1.addCell(cell1); document.add(table1); // TABLE 2 table2 = new PdfPTable(new float[] { 9, 1 }); table2.setWidthPercentage(100); // First column cell2 = new PdfPCell(); cell2.setBorder(PdfPCell.NO_BORDER); cell2.setPaddingTop(5); Image long_line_img = Image.getInstance(LONG_LINE_IMAGE); long_line_img.setBorderWidth(10); long_line_img.setBorderColor(BaseColor.WHITE); long_line_img.scaleToFit(475, 50); cell2.addElement(long_line_img); table2.addCell(cell2); // Second column cell2 = new PdfPCell(); cell2.setBorder(PdfPCell.NO_BORDER); table2.addCell(cell2); document.add(table2); // TABLE 3 List<String> rankedSkills = selectSkills(skills); if (personalCharacteristics.size() != 0 && rankedSkills.size() != 0) { table3 = new PdfPTable(new float[] { 6 }); table3.setWidthPercentage(100); table3.setSpacingBefore(5); //First column cell3 = new PdfPCell(); cell3.setBorder(PdfPCell.NO_BORDER); paragraph2 = new Paragraph( "Me defino como una persona de carcter " + personalCharacteristics.get(1).toLowerCase() + " y " + personalCharacteristics.get(0).toLowerCase() + ".", font3); paragraph2.setAlignment(Paragraph.ALIGN_LEFT); cell3.setPaddingRight(15); cell3.setPaddingLeft(50); cell3.setPaddingTop(-1); cell3.addElement(paragraph2); table3.addCell(cell3); //First column cell3 = new PdfPCell(); cell3.setBorder(PdfPCell.NO_BORDER); paragraph2 = new Paragraph("Entre mis puntos fuertes destacan las " + rankedSkills.get(0).toLowerCase() + " y las " + rankedSkills.get(1).toLowerCase() + ".", font3); cell3.setBorder(PdfPCell.NO_BORDER); paragraph2.setAlignment(Paragraph.ALIGN_LEFT); cell3.setPaddingRight(15); cell3.setPaddingLeft(50); cell3.addElement(paragraph2); table3.addCell(cell3); //First column cell3 = new PdfPCell(); cell3.setBorder(PdfPCell.NO_BORDER); paragraph2 = new Paragraph( "Considero que soy una persona activa que presenta " + rankedSkills.get(2).toLowerCase() + ".", font3); cell3.setBorder(PdfPCell.NO_BORDER); paragraph2.setAlignment(Paragraph.ALIGN_LEFT); cell3.setPaddingRight(15); cell3.setPaddingLeft(50); cell3.addElement(paragraph2); table3.addCell(cell3); //First column cell3 = new PdfPCell(); cell3.setBorder(PdfPCell.NO_BORDER); paragraph2 = new Paragraph("Adems, una de las caractersticas que me define es que soy " + personalCharacteristics.get(2).toLowerCase() + ".", font3); cell3.setBorder(PdfPCell.NO_BORDER); paragraph2.setAlignment(Paragraph.ALIGN_LEFT); cell3.setPaddingRight(15); cell3.setPaddingLeft(50); cell3.addElement(paragraph2); table3.addCell(cell3); document.add(table3); } }
From source file:utils.pdf.cv_templates.Template4.java
private void addPersonalInformation(User user) throws DocumentException { Paragraph paragraph; PdfPCell cell;/*ww w . j av a2 s .co m*/ PdfPTable table; table = new PdfPTable(new float[] { 1f, 1.45f, 0.8f }); table.setWidthPercentage(100); table.setSpacingBefore(5); //First column cell = new PdfPCell(); cell.setBorder(PdfPCell.RIGHT); paragraph = new Paragraph("INFORMACIN PERSONAL", font1); cell.setBorder(PdfPCell.RIGHT); paragraph.setAlignment(Paragraph.ALIGN_RIGHT); cell.setPaddingRight(10); cell.addElement(paragraph); table.addCell(cell); //Second column cell = new PdfPCell(); cell.setBorder(PdfPCell.NO_BORDER); cell.setPaddingLeft(10); cell.setPaddingTop(0); paragraph = new Paragraph(""); cell.setBorder(PdfPCell.NO_BORDER); table.addCell(cell); // IMG column cell = new PdfPCell(); cell.setPaddingLeft(10); cell.setPaddingTop(0); cell.setBorder(PdfPCell.NO_BORDER); paragraph = new Paragraph(""); cell.addElement(paragraph); table.addCell(cell); //First column cell = new PdfPCell(); cell.setBorder(PdfPCell.RIGHT); paragraph = new Paragraph("Nombre completo", font2); cell.setBorder(PdfPCell.RIGHT); paragraph.setAlignment(Paragraph.ALIGN_RIGHT); cell.setPaddingRight(10); cell.addElement(paragraph); table.addCell(cell); //Second column cell = new PdfPCell(); cell.setPaddingLeft(10); cell.setPaddingTop(0); cell.setBorder(PdfPCell.NO_BORDER); paragraph = new Paragraph(user.name + " " + user.surnames, font2); cell.addElement(paragraph); table.addCell(cell); // IMG column cell = new PdfPCell(); cell.setPaddingLeft(10); cell.setPaddingTop(0); cell.setBorder(PdfPCell.NO_BORDER); paragraph = new Paragraph(""); cell.addElement(paragraph); table.addCell(cell); //First column cell = new PdfPCell(); cell.setBorder(PdfPCell.RIGHT); paragraph = new Paragraph("Direccin", font2); cell.setBorder(PdfPCell.RIGHT); paragraph.setAlignment(Paragraph.ALIGN_RIGHT); cell.setPaddingRight(10); cell.addElement(paragraph); table.addCell(cell); //Second column cell = new PdfPCell(); cell.setPaddingLeft(10); cell.setPaddingTop(0); cell.setBorder(PdfPCell.NO_BORDER); paragraph = new Paragraph("Calle " + user.residenceAddress + " , " + " N " + user.residenceNumber + " , " + " CP: " + user.residenceZipCode + " , " + user.residenceCity, font2); cell.addElement(paragraph); table.addCell(cell); // IMG column cell = new PdfPCell(); cell.setPaddingLeft(10); cell.setPaddingTop(0); cell.setBorder(PdfPCell.NO_BORDER); paragraph = new Paragraph(""); cell.addElement(paragraph); table.addCell(cell); //First column cell = new PdfPCell(); cell.setBorder(PdfPCell.RIGHT); paragraph = new Paragraph("Telfono", font2); cell.setBorder(PdfPCell.RIGHT); paragraph.setAlignment(Paragraph.ALIGN_RIGHT); cell.setPaddingRight(10); cell.addElement(paragraph); table.addCell(cell); //Second column cell = new PdfPCell(); cell.setPaddingLeft(10); cell.setPaddingTop(0); cell.setBorder(PdfPCell.NO_BORDER); paragraph = new Paragraph(user.phoneNumber, font2); cell.addElement(paragraph); table.addCell(cell); // IMG column cell = new PdfPCell(); cell.setPaddingLeft(10); cell.setPaddingTop(0); cell.setBorder(PdfPCell.NO_BORDER); paragraph = new Paragraph(""); cell.addElement(paragraph); table.addCell(cell); //First column cell = new PdfPCell(); cell.setBorder(PdfPCell.RIGHT); paragraph = new Paragraph("Email", font2); cell.setBorder(PdfPCell.RIGHT); paragraph.setAlignment(Paragraph.ALIGN_RIGHT); cell.setPaddingRight(10); cell.addElement(paragraph); table.addCell(cell); //Second column cell = new PdfPCell(); cell.setPaddingLeft(10); cell.setPaddingTop(0); cell.setBorder(PdfPCell.NO_BORDER); paragraph = new Paragraph(user.email, font2); cell.addElement(paragraph); table.addCell(cell); // IMG column cell = new PdfPCell(); cell.setPaddingLeft(10); cell.setPaddingTop(0); cell.setBorder(PdfPCell.NO_BORDER); paragraph = new Paragraph(""); cell.addElement(paragraph); table.addCell(cell); //First column cell = new PdfPCell(); cell.setBorder(PdfPCell.RIGHT); paragraph = new Paragraph("Fecha de nacimiento", font2); cell.setBorder(PdfPCell.RIGHT); paragraph.setAlignment(Paragraph.ALIGN_RIGHT); cell.setPaddingRight(10); cell.addElement(paragraph); table.addCell(cell); //Second column cell = new PdfPCell(); cell.setPaddingLeft(10); cell.setPaddingTop(0); cell.setBorder(PdfPCell.NO_BORDER); paragraph = new Paragraph(user.birthDate, font2); cell.addElement(paragraph); table.addCell(cell); // IMG column cell = new PdfPCell(); cell.setPaddingLeft(10); cell.setPaddingTop(0); cell.setBorder(PdfPCell.NO_BORDER); paragraph = new Paragraph(""); cell.addElement(paragraph); table.addCell(cell); document.add(table); }
From source file:utils.pdf.cv_templates.Template4.java
private void addProfessionalExperience(List<ProfessionalExperience> experienceList) throws DocumentException { Paragraph paragraph; PdfPCell cell;//w ww . j a va 2s .c o m PdfPTable table; for (int i = 0; i < experienceList.size(); i++) { table = new PdfPTable(new float[] { 1f, 2.25f }); table.setWidthPercentage(100); table.setSpacingBefore(5); //First column cell = new PdfPCell(); cell.setBorder(PdfPCell.RIGHT); if (i == 0) { paragraph = new Paragraph("EXPERIENCIA PROFESIONAL", font1); cell.setBorder(PdfPCell.RIGHT); } else { paragraph = new Paragraph(""); } paragraph.setAlignment(Paragraph.ALIGN_RIGHT); cell.setPaddingRight(10); cell.addElement(paragraph); table.addCell(cell); //Second column cell = new PdfPCell(); cell.setPaddingLeft(10); cell.setPaddingTop(0); cell.setBorder(PdfPCell.NO_BORDER); paragraph = new Paragraph(""); cell.addElement(paragraph); table.addCell(cell); //First column cell = new PdfPCell(); cell.setBorder(PdfPCell.RIGHT); paragraph = new Paragraph("Ttulo", font2); cell.setBorder(PdfPCell.RIGHT); paragraph.setAlignment(Paragraph.ALIGN_RIGHT); cell.setPaddingRight(10); cell.addElement(paragraph); table.addCell(cell); //Second column cell = new PdfPCell(); cell.setPaddingLeft(10); cell.setPaddingTop(0); cell.setBorder(PdfPCell.NO_BORDER); paragraph = new Paragraph(experienceList.get(i).job, font2); cell.addElement(paragraph); table.addCell(cell); //First column cell = new PdfPCell(); cell.setBorder(PdfPCell.RIGHT); paragraph = new Paragraph("Empresa y lugar", font2); cell.setBorder(PdfPCell.RIGHT); paragraph.setAlignment(Paragraph.ALIGN_RIGHT); cell.setPaddingRight(10); cell.addElement(paragraph); table.addCell(cell); //Second column cell = new PdfPCell(); cell.setPaddingLeft(10); cell.setPaddingTop(0); cell.setBorder(PdfPCell.NO_BORDER); paragraph = new Paragraph(experienceList.get(i).company, font2); cell.addElement(paragraph); table.addCell(cell); //First column cell = new PdfPCell(); cell.setBorder(PdfPCell.RIGHT); paragraph = new Paragraph("Fecha", font2); cell.setBorder(PdfPCell.RIGHT); paragraph.setAlignment(Paragraph.ALIGN_RIGHT); cell.setPaddingRight(10); cell.addElement(paragraph); table.addCell(cell); //Second column cell = new PdfPCell(); cell.setPaddingLeft(10); cell.setPaddingTop(0); cell.setBorder(PdfPCell.NO_BORDER); paragraph = new Paragraph(experienceList.get(i).startDate + " - " + experienceList.get(i).endDate, font2); cell.addElement(paragraph); table.addCell(cell); document.add(table); } }
From source file:utils.pdf.cv_templates.Template4.java
private void addStudies(User user) throws DocumentException { Paragraph paragraph; PdfPCell cell;/* w ww. j ava 2s . c om*/ PdfPTable table; table = new PdfPTable(new float[] { 1f, 2.25f }); table.setWidthPercentage(100); table.setSpacingBefore(5); //First column cell = new PdfPCell(); cell.setBorder(PdfPCell.RIGHT); if (!user.studyTitle.equals("")) { paragraph = new Paragraph("EXPERIENCIA ACADMICA", font1); cell.setBorder(PdfPCell.RIGHT); } else { paragraph = new Paragraph(""); } paragraph.setAlignment(Paragraph.ALIGN_RIGHT); cell.setPaddingRight(10); cell.addElement(paragraph); table.addCell(cell); //Second column cell = new PdfPCell(); cell.setPaddingLeft(10); cell.setPaddingTop(0); cell.setBorder(PdfPCell.NO_BORDER); paragraph = new Paragraph(""); cell.addElement(paragraph); table.addCell(cell); //First column cell = new PdfPCell(); cell.setBorder(PdfPCell.RIGHT); paragraph = new Paragraph("Ttulo", font2); cell.setBorder(PdfPCell.RIGHT); paragraph.setAlignment(Paragraph.ALIGN_RIGHT); cell.setPaddingRight(10); cell.addElement(paragraph); table.addCell(cell); //Second column cell = new PdfPCell(); cell.setPaddingLeft(10); cell.setPaddingTop(0); cell.setBorder(PdfPCell.NO_BORDER); paragraph = new Paragraph(user.studyTitle, font2); cell.addElement(paragraph); table.addCell(cell); //First column cell = new PdfPCell(); cell.setBorder(PdfPCell.RIGHT); paragraph = new Paragraph("Centro y lugar", font2); cell.setBorder(PdfPCell.RIGHT); paragraph.setAlignment(Paragraph.ALIGN_RIGHT); cell.setPaddingRight(10); cell.addElement(paragraph); table.addCell(cell); //Second column cell = new PdfPCell(); cell.setPaddingLeft(10); cell.setPaddingTop(0); cell.setBorder(PdfPCell.NO_BORDER); paragraph = new Paragraph(user.studyLocation, font2); cell.addElement(paragraph); table.addCell(cell); document.add(table); }
From source file:utils.pdf.cv_templates.Template4.java
private void addSoftware(List<Software> softwareList) throws DocumentException { Paragraph paragraph; PdfPCell cell;// w w w . ja va 2s. co m PdfPTable table; for (int i = 0; i < softwareList.size(); i++) { table = new PdfPTable(new float[] { 1f, 2.25f }); table.setWidthPercentage(100); table.setSpacingBefore(5); //First column cell = new PdfPCell(); cell.setBorder(PdfPCell.RIGHT); if (i == 0) { paragraph = new Paragraph("PROGRAMAS INFORM?TICOS", font1); cell.setBorder(PdfPCell.RIGHT); } else { paragraph = new Paragraph(""); } paragraph.setAlignment(Paragraph.ALIGN_RIGHT); cell.setPaddingRight(10); cell.addElement(paragraph); table.addCell(cell); //Second column cell = new PdfPCell(); cell.setPaddingLeft(10); cell.setPaddingTop(0); cell.setBorder(PdfPCell.NO_BORDER); paragraph = new Paragraph(""); cell.addElement(paragraph); table.addCell(cell); //First column cell = new PdfPCell(); cell.setBorder(PdfPCell.RIGHT); paragraph = new Paragraph("Nombre", font2); cell.setBorder(PdfPCell.RIGHT); paragraph.setAlignment(Paragraph.ALIGN_RIGHT); cell.setPaddingRight(10); cell.addElement(paragraph); table.addCell(cell); //Second column cell = new PdfPCell(); cell.setPaddingLeft(10); cell.setPaddingTop(0); cell.setBorder(PdfPCell.NO_BORDER); paragraph = new Paragraph(softwareList.get(i).software, font2); cell.addElement(paragraph); table.addCell(cell); //First column cell = new PdfPCell(); cell.setBorder(PdfPCell.RIGHT); paragraph = new Paragraph("Nivel", font2); cell.setBorder(PdfPCell.RIGHT); paragraph.setAlignment(Paragraph.ALIGN_RIGHT); cell.setPaddingRight(10); cell.addElement(paragraph); table.addCell(cell); //Second column cell = new PdfPCell(); cell.setPaddingLeft(10); cell.setPaddingTop(0); cell.setBorder(PdfPCell.NO_BORDER); paragraph = new Paragraph(softwareList.get(i).level, font2); cell.addElement(paragraph); table.addCell(cell); document.add(table); } }
From source file:utils.pdf.cv_templates.Template4.java
private void addCourses(List<Course> courseList) throws DocumentException { Paragraph paragraph; PdfPCell cell;/*from w w w . jav a 2 s. c om*/ PdfPTable table; for (int i = 0; i < courseList.size(); i++) { table = new PdfPTable(new float[] { 1f, 2.25f }); table.setWidthPercentage(100); table.setSpacingBefore(5); //First column cell = new PdfPCell(); cell.setBorder(PdfPCell.RIGHT); if (i == 0) { paragraph = new Paragraph("CURSOS", font1); cell.setBorder(PdfPCell.RIGHT); } else { paragraph = new Paragraph(""); } paragraph.setAlignment(Paragraph.ALIGN_RIGHT); cell.setPaddingRight(10); cell.addElement(paragraph); table.addCell(cell); //Second column cell = new PdfPCell(); cell.setPaddingLeft(10); cell.setPaddingTop(0); cell.setBorder(PdfPCell.NO_BORDER); paragraph = new Paragraph(""); cell.addElement(paragraph); table.addCell(cell); //First column cell = new PdfPCell(); cell.setBorder(PdfPCell.RIGHT); paragraph = new Paragraph("Ttulo", font2); cell.setBorder(PdfPCell.RIGHT); paragraph.setAlignment(Paragraph.ALIGN_RIGHT); cell.setPaddingRight(10); cell.addElement(paragraph); table.addCell(cell); //Second column cell = new PdfPCell(); cell.setPaddingLeft(10); cell.setPaddingTop(0); cell.setBorder(PdfPCell.NO_BORDER); paragraph = new Paragraph(courseList.get(i).name, font2); cell.addElement(paragraph); table.addCell(cell); //First column cell = new PdfPCell(); cell.setBorder(PdfPCell.RIGHT); paragraph = new Paragraph("Centro y lugar", font2); cell.setBorder(PdfPCell.RIGHT); paragraph.setAlignment(Paragraph.ALIGN_RIGHT); cell.setPaddingRight(10); cell.addElement(paragraph); table.addCell(cell); //Second column cell = new PdfPCell(); cell.setPaddingLeft(10); cell.setPaddingTop(0); cell.setBorder(PdfPCell.NO_BORDER); paragraph = new Paragraph(courseList.get(i).company, font2); cell.addElement(paragraph); table.addCell(cell); //First column cell = new PdfPCell(); cell.setBorder(PdfPCell.RIGHT); paragraph = new Paragraph("Nmero de horas", font2); cell.setBorder(PdfPCell.RIGHT); paragraph.setAlignment(Paragraph.ALIGN_RIGHT); cell.setPaddingRight(10); cell.addElement(paragraph); table.addCell(cell); //Second column cell = new PdfPCell(); cell.setPaddingLeft(10); cell.setPaddingTop(0); cell.setBorder(PdfPCell.NO_BORDER); paragraph = new Paragraph(courseList.get(i).length, font2); cell.addElement(paragraph); table.addCell(cell); document.add(table); } }
From source file:utils.pdf.cv_templates.Template4.java
private void addLanguage(List<Language> languageList) throws DocumentException { Paragraph paragraph; PdfPCell cell;//from www . j a v a2 s . c om PdfPTable table; for (int i = 0; i < languageList.size(); i++) { table = new PdfPTable(new float[] { 1f, 2.25f }); table.setWidthPercentage(100); table.setSpacingBefore(5); //First column cell = new PdfPCell(); cell.setBorder(PdfPCell.RIGHT); if (i == 0) { paragraph = new Paragraph("IDIOMAS", font1); cell.setBorder(PdfPCell.RIGHT); } else { paragraph = new Paragraph(""); } paragraph.setAlignment(Paragraph.ALIGN_RIGHT); cell.setPaddingRight(10); cell.addElement(paragraph); table.addCell(cell); //Second column cell = new PdfPCell(); cell.setPaddingLeft(10); cell.setPaddingTop(0); cell.setBorder(PdfPCell.NO_BORDER); paragraph = new Paragraph(""); cell.addElement(paragraph); table.addCell(cell); //First column cell = new PdfPCell(); cell.setBorder(PdfPCell.RIGHT); paragraph = new Paragraph("Nombre", font2); cell.setBorder(PdfPCell.RIGHT); paragraph.setAlignment(Paragraph.ALIGN_RIGHT); cell.setPaddingRight(10); cell.addElement(paragraph); table.addCell(cell); //Second column cell = new PdfPCell(); cell.setPaddingLeft(10); cell.setPaddingTop(0); cell.setBorder(PdfPCell.NO_BORDER); paragraph = new Paragraph(languageList.get(i).language, font2); cell.addElement(paragraph); table.addCell(cell); //First column cell = new PdfPCell(); cell.setBorder(PdfPCell.RIGHT); paragraph = new Paragraph("Nivel", font2); cell.setBorder(PdfPCell.RIGHT); paragraph.setAlignment(Paragraph.ALIGN_RIGHT); cell.setPaddingRight(10); cell.addElement(paragraph); table.addCell(cell); //Second column cell = new PdfPCell(); cell.setPaddingLeft(10); cell.setPaddingTop(0); cell.setBorder(PdfPCell.NO_BORDER); paragraph = new Paragraph(languageList.get(i).level, font2); cell.addElement(paragraph); table.addCell(cell); document.add(table); } }
From source file:utils.pdf.cv_templates.Template4.java
private void addSkills(User user, List<String> personalCharacteristics, List<Skill> skills) throws DocumentException { Paragraph paragraph; PdfPCell cell;/*w ww . j a v a 2 s. co m*/ PdfPTable table; List<String> rankedSkills = selectSkills(skills); if (personalCharacteristics.size() != 0 && rankedSkills.size() != 0) { table = new PdfPTable(new float[] { 1f }); table.setWidthPercentage(100); table.setSpacingBefore(5); //First column cell = new PdfPCell(); cell.setBorder(PdfPCell.NO_BORDER); paragraph = new Paragraph("HABILIDADES PERSONALES", font1); cell.setBorder(PdfPCell.NO_BORDER); paragraph.setAlignment(Paragraph.ALIGN_LEFT); cell.setPaddingRight(10); cell.addElement(paragraph); table.addCell(cell); //First column cell = new PdfPCell(); cell.setBorder(PdfPCell.NO_BORDER); paragraph = new Paragraph( "Me defino como una persona de carcter " + personalCharacteristics.get(1).toLowerCase() + " y " + personalCharacteristics.get(0).toLowerCase() + ".", font2); cell.setBorder(PdfPCell.NO_BORDER); paragraph.setAlignment(Paragraph.ALIGN_LEFT); cell.setPaddingRight(10); cell.addElement(paragraph); table.addCell(cell); //First column cell = new PdfPCell(); cell.setBorder(PdfPCell.NO_BORDER); paragraph = new Paragraph("Entre mis puntos fuertes destacan las " + rankedSkills.get(0).toLowerCase() + " y las " + rankedSkills.get(1).toLowerCase() + ".", font2); cell.setBorder(PdfPCell.NO_BORDER); paragraph.setAlignment(Paragraph.ALIGN_LEFT); cell.setPaddingRight(10); cell.addElement(paragraph); table.addCell(cell); //First column cell = new PdfPCell(); cell.setBorder(PdfPCell.NO_BORDER); paragraph = new Paragraph( "Considero que soy una persona activa que presenta " + rankedSkills.get(2).toLowerCase() + ".", font2); cell.setBorder(PdfPCell.NO_BORDER); paragraph.setAlignment(Paragraph.ALIGN_LEFT); cell.setPaddingRight(10); cell.addElement(paragraph); table.addCell(cell); //First column cell = new PdfPCell(); cell.setBorder(PdfPCell.NO_BORDER); paragraph = new Paragraph("Adems, una de las caractersticas que me define es que soy " + personalCharacteristics.get(2).toLowerCase() + ".", font2); cell.setBorder(PdfPCell.NO_BORDER); paragraph.setAlignment(Paragraph.ALIGN_LEFT); cell.setPaddingRight(10); cell.addElement(paragraph); table.addCell(cell); if (!user.drivingLicense.equals("No tengo carnet")) { //First column cell = new PdfPCell(); cell.setBorder(PdfPCell.NO_BORDER); paragraph = new Paragraph("Permiso de conducir: " + user.drivingLicense + ".", font2); cell.setBorder(PdfPCell.NO_BORDER); paragraph.setAlignment(Paragraph.ALIGN_LEFT); cell.setPaddingRight(10); cell.addElement(paragraph); table.addCell(cell); } document.add(table); } }
From source file:utils.PrintInvoice.java
public void getDocument() { try {/*w w w .j a v a 2 s .c o m*/ PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("SaleBill#" + salebill.getId() + ".pdf")); document.open(); //////////////////////////////////////////////////////////////////////////////////// ///////////////////Start Document Here///////////////////////////////// PdfContentByte directContent = writer.getDirectContent(); Paragraph p1 = new Paragraph("SALE BILL"); p1.setFont(FONT[4]); p1.setAlignment(Element.ALIGN_CENTER); document.add(p1); //show the company details here. Phrase company = new Phrase(new Chunk("BIO PHARMA\nAKOT 444101(M.S)", FONT[3])); document.add(company); document.add(new Phrase( "\nLicense No : 20B : AK-88888\n 21B : AK-88889\n Mobile : " + SessionClass.getInstance().getMobileNumber(), FONT[2])); // Phrase mobNum = new Phrase(" Mobile : "+SessionClass.getInstance().getMobileNumber() ); // mobNum.setFont(FONT[2]); // ColumnText.showTextAligned(directContent, Element.ALIGN_LEFT, mobNum, 35, 710, 0); System.out.println(dateFormatter.format(salebill.getBillDate())); //show the invoice details // String txt = "Bill No. : " + salebill.getId()+"\nBill Date : " + dateFormatter.format(salebill.getBillDate()) +; Phrase invoiceDetails = new Phrase("Bill No. : " + salebill.getId()); ColumnText.showTextAligned(directContent, Element.ALIGN_LEFT, invoiceDetails, 400, 693, 0); invoiceDetails = new Phrase("Bill Date : " + dateFormatter2.format(salebill.getBillDate())); ColumnText.showTextAligned(directContent, Element.ALIGN_LEFT, invoiceDetails, 400, 681, 0); invoiceDetails = new Phrase("Mode of Payment : " + salebill.getMode()); ColumnText.showTextAligned(directContent, Element.ALIGN_LEFT, invoiceDetails, 400, 668, 0); //show the customer details Customer c = salebill.getCustomerId(); Phrase custDetails = new Phrase("SOLD TO", FONT[3]); ColumnText.showTextAligned(directContent, Element.ALIGN_LEFT, custDetails, 35, 693, 0); custDetails = new Phrase(c.getCompanyName()); ColumnText.showTextAligned(directContent, Element.ALIGN_LEFT, custDetails, 35, 681, 0); custDetails = new Phrase(c.getSiteAddress()); ColumnText.showTextAligned(directContent, Element.ALIGN_LEFT, custDetails, 35, 668, 0); custDetails = new Phrase("Licence : " + c.getLicenceNo()); ColumnText.showTextAligned(directContent, Element.ALIGN_LEFT, custDetails, 35, 655, 0); document.add(Chunk.NEWLINE); document.add(Chunk.NEWLINE); document.add(Chunk.NEWLINE); document.add(Chunk.NEWLINE); document.add(Chunk.NEWLINE); //Item Particulars are shown here PdfPTable table = new PdfPTable(7); table.setTotalWidth(new float[] { 175, 80, 80, 50, 50, 50, 75 }); table.setHeaderRows(1); //headers table.getDefaultCell().setBackgroundColor(BaseColor.LIGHT_GRAY); table.addCell("Particulars"); table.addCell("Batch"); table.addCell("Expiry"); table.addCell("MRP"); table.addCell("Rate"); table.addCell("Qnty"); table.addCell("SubTotal"); table.getDefaultCell().setBackgroundColor(null); table.setSpacingAfter(5.0f); List<SaleBillPharmaItem> items = salebill.getSaleBillPharmaItemList(); for (int i = 0; i < items.size(); i++) { PdfPCell desc = new PdfPCell(new Phrase(items.get(i).getItemName())); table.addCell(desc); PdfPCell batch = new PdfPCell(new Phrase(items.get(i).getBatch())); table.addCell(batch); PdfPCell expiry = null; Date tDate = null; try { tDate = dateFormatter2.parse(items.get(i).getExpDate()); } catch (ParseException ex) { Logger.getLogger(PrintInvoice.class.getName()).log(Level.SEVERE, null, ex); } expiry = new PdfPCell(new Phrase(dateFormatter.format(tDate))); table.addCell(expiry); PdfPCell mrp = new PdfPCell(new Phrase(items.get(i).getMrp() + "")); // //mrp.setBorderColor(BaseColor.WHITE); // mrp.setBorderColorLeft(BaseColor.BLACK); // mrp.setBorderColorRight(BaseColor.WHITE); table.addCell(mrp); PdfPCell rate = new PdfPCell(new Phrase(items.get(i).getItemRate() + "")); // //rate.setBorderColor(BaseColor.WHITE); // rate.setBorderColorLeft(BaseColor.BLACK); // rate.setBorderColorRight(BaseColor.WHITE); table.addCell(rate); PdfPCell quantity = new PdfPCell(new Phrase(items.get(i).getQnty() + "")); // //quantity.setBorderColor(BaseColor.WHITE); // quantity.setBorderColorLeft(BaseColor.BLACK); // quantity.setBorderColorRight(BaseColor.WHITE); table.addCell(quantity); PdfPCell subtotal = new PdfPCell(new Phrase(items.get(i).getAmt() + "")); // //subtotal.setBorderColor(BaseColor.WHITE); // subtotal.setBorderColorLeft(BaseColor.BLACK); // subtotal.setBorderColorRight(BaseColor.WHITE); table.addCell(subtotal); } //now show the sub details //PdfPCell finalCell = new PdfPCell(new Phrase("Total VAT Amt : Rs " + salebill.getTotalVat() + " Total Amount : Rs ")); //Todo change code here to show vat amount when there is vat number PdfPCell finalCell = new PdfPCell( new Phrase("Total VAT Amt : Rs " + salebill.getTotalVat() + " Total Amount : Rs ")); finalCell.setHorizontalAlignment(Element.ALIGN_RIGHT); finalCell.setColspan(6); table.addCell(finalCell); table.addCell("" + salebill.getTotalAmt()); PdfPCell cdCell = new PdfPCell(new Phrase("Cash Discount (2 %) : (-) Rs")); cdCell.setColspan(6); cdCell.setHorizontalAlignment(Element.ALIGN_RIGHT); table.addCell(cdCell); table.addCell("" + salebill.getDiscount()); PdfPCell finalAmtCell = new PdfPCell(new Phrase("Final Amount : Rs")); finalAmtCell.setColspan(6); finalAmtCell.setHorizontalAlignment(Element.ALIGN_RIGHT); table.addCell(finalAmtCell); table.addCell("" + salebill.getFinalAmt()); document.add(table); document.add(Chunk.NEWLINE); document.add(Chunk.NEWLINE); Paragraph sign = new Paragraph(new Chunk("Authorized signatory\n(BIO PHARMA)")); sign.setAlignment(Element.ALIGN_RIGHT); document.add(sign); document.add(Chunk.NEWLINE); document.add(Chunk.NEWLINE); document.add(Chunk.NEWLINE); Paragraph p = new Paragraph("THANK YOU FOR YOUR BUSINESS"); p.setFont(FONT[4]); p.setAlignment(Element.ALIGN_CENTER); document.add(p); ///////////////////End Documnet here////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////// document.close(); // no need to close PDFwriter? } catch (DocumentException | FileNotFoundException e) { //LOGGER e.printStackTrace(); Stage dialogStage = new Stage(); dialogStage.setTitle("Printing Error"); dialogStage.initModality(Modality.WINDOW_MODAL); dialogStage.setScene(new Scene(VBoxBuilder.create() .children(new Text( "The file to be printed is already open \n. Please close the file and Print Again")) .alignment(Pos.CENTER).padding(new Insets(50)).build())); dialogStage.show(); } }