List of usage examples for com.itextpdf.text Paragraph Paragraph
public Paragraph(float leading, String string)
Paragraph
with a certain String
and a certain leading. From source file:be.mxs.common.util.pdf.general.dossierCreators.StaffDossierPDFCreator.java
private void addDisciplinaryRecordDetails(PdfPTable table, DisciplinaryRecord disRec) { if (disRec.followUp.length() > 0) { PdfPTable detailsTable = new PdfPTable(10); detailsTable.setWidthPercentage(100); // follow-up in grey and italic //detailsTable.addCell(createValueCell(disRec.followUp.replaceAll("\r\n"," "),10)); Font font = FontFactory.getFont(FontFactory.HELVETICA, 7, Font.ITALIC); font.setColor(BaseColor.GRAY);//from w w w. ja va 2 s .c om cell = new PdfPCell(new Paragraph(disRec.followUp.replaceAll("\r\n", " "), font)); cell.setColspan(10); cell.setBorder(PdfPCell.BOX); cell.setBorderColor(innerBorderColor); cell.setVerticalAlignment(PdfPCell.ALIGN_TOP); cell.setHorizontalAlignment(PdfPCell.ALIGN_LEFT); detailsTable.addCell(cell); table.addCell(createCell(new PdfPCell(detailsTable), table.getNumberOfColumns(), PdfPCell.ALIGN_CENTER, PdfPCell.BOX)); } }
From source file:be.mxs.common.util.pdf.general.dossierCreators.StaffDossierPDFCreator.java
private void addLeaveDetails(PdfPTable table, Leave leave) { if (leave.comment.length() > 0) { PdfPTable detailsTable = new PdfPTable(10); detailsTable.setWidthPercentage(100); // follow-up in grey and italic //detailsTable.addCell(createValueCell(leave.comment.replaceAll("\r\n"," "),10)); Font font = FontFactory.getFont(FontFactory.HELVETICA, 7, Font.ITALIC); font.setColor(BaseColor.GRAY);/*from w w w . j a v a 2 s.c o m*/ cell = new PdfPCell(new Paragraph(leave.comment.replaceAll("\r\n", " "), font)); cell.setColspan(10); cell.setBorder(PdfPCell.BOX); cell.setBorderColor(innerBorderColor); cell.setVerticalAlignment(PdfPCell.ALIGN_TOP); cell.setHorizontalAlignment(PdfPCell.ALIGN_LEFT); detailsTable.addCell(cell); table.addCell(createCell(new PdfPCell(detailsTable), table.getNumberOfColumns(), PdfPCell.ALIGN_CENTER, PdfPCell.BOX)); } }
From source file:be.mxs.common.util.pdf.general.dossierCreators.StaffDossierPDFCreator.java
private void addCareerDetails(PdfPTable table, Career career) { if (career.comment.length() > 0) { PdfPTable detailsTable = new PdfPTable(10); detailsTable.setWidthPercentage(100); // comment in grey and italic //detailsTable.addCell(createValueCell(career.comment.replaceAll("\r\n"," "),10)); Font font = FontFactory.getFont(FontFactory.HELVETICA, 7, Font.ITALIC); font.setColor(BaseColor.GRAY);//from w w w. ja va 2s . c o m cell = new PdfPCell(new Paragraph(career.comment.replaceAll("\r\n", " "), font)); cell.setColspan(10); cell.setBorder(PdfPCell.BOX); cell.setBorderColor(innerBorderColor); cell.setVerticalAlignment(PdfPCell.ALIGN_TOP); cell.setHorizontalAlignment(PdfPCell.ALIGN_LEFT); detailsTable.addCell(cell); table.addCell(createCell(new PdfPCell(detailsTable), table.getNumberOfColumns(), PdfPCell.ALIGN_CENTER, PdfPCell.BOX)); } }
From source file:be.rheynaerde.poolsheets.ClubPoolSheet.java
License:Open Source License
@Override protected void buildTable(Document document) throws DocumentException { int columnCount = configuration.getNrOfPlayers() + configuration.getSummaryColumnCount() + 3; int nameCellWidth = 5; PdfPTable table = new PdfPTable(columnCount); table.setHorizontalAlignment(PdfPTable.ALIGN_CENTER); table.setTotalWidth(/* w w w . jav a 2 s . c om*/ (configuration.getNrOfPlayers() + 1 + nameCellWidth + 0.1f + configuration.getSummaryColumnCount()) * configuration.getSquareCellSize()); table.setLockedWidth(true); float[] widths = new float[columnCount]; widths[0] = 1f * nameCellWidth; for (int i = 1; i < widths.length; i++) { widths[i] = 1f; } widths[widths.length - 1 - configuration.getSummaryColumnCount()] = 0.1f; table.setWidths(widths); PdfPCell cell = new PdfPCell(new Paragraph(configuration.getTitle(), configuration.getTitleFont())); cell.setColspan(columnCount); cell.setPaddingBottom(configuration.getSquareCellSize() / 2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(cell); { table.addCell(getHeaderCell(bundle.getString("name"))); table.addCell(getSolidCell()); for (int i = 0; i < configuration.getNrOfPlayers(); i++) { table.addCell(getHeaderCell(Integer.toString(i + 1))); } table.addCell(new PdfPCell()); //spacer column for (int i = 0; i < configuration.getSummaryColumnCount(); i++) { table.addCell(getHeaderCell(configuration.getSummaryColumnName(i))); } } for (int i = 0; i < configuration.getNrOfPlayers(); i++) { table.addCell(configuration.getNamePlayer(i + 1) == null ? "" : configuration.getNamePlayer(i + 1)); table.addCell(getHeaderCell(Integer.toString(i + 1))); for (int j = 0; j < i; j++) { String result = configuration.getResult(i + 1, j + 1); PdfPCell resultCell = new PdfPCell(new Phrase(result == null ? "" : result)); resultCell.setHorizontalAlignment(Element.ALIGN_CENTER); resultCell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(resultCell); } table.addCell(getSolidCell()); for (int j = i + 1; j < configuration.getNrOfPlayers(); j++) { String result = configuration.getResult(i + 1, j + 1); PdfPCell resultCell = new PdfPCell(new Phrase(result == null ? "" : result)); resultCell.setHorizontalAlignment(Element.ALIGN_CENTER); resultCell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(resultCell); } table.addCell(new PdfPCell()); //spacer column for (int j = 0; j < configuration.getSummaryColumnCount(); j++) { String result = configuration.getSummaryColumnValue(i + 1, j); PdfPCell summaryCell = new PdfPCell(new Phrase(result == null ? "" : result)); summaryCell.setHorizontalAlignment(Element.ALIGN_CENTER); summaryCell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(summaryCell); } } document.add(table); }
From source file:be.roots.taconic.pricingguide.service.PDFServiceImpl.java
License:Open Source License
private PdfPTable buildModelPricingTable(Pricing pricing) { final PdfPTable pricingTable = new PdfPTable(pricing.getNumberOfHeaderItems()); pricingTable.addCell(cell(new Paragraph(pricing.getCategory(), iTextUtil.getFontModelCategory()), pricing.getNumberOfHeaderItems())); pricingTable.addCell(cell(new Paragraph(" "), pricing.getNumberOfHeaderItems())); if (pricing.isQuantities()) { pricingTable.addCell(cellH(new Paragraph("Quantity", iTextUtil.getFontModelPricingTitle()))); }/* w ww. j av a 2s.com*/ if (pricing.isAge()) { pricingTable.addCell(cellH(new Paragraph("Age (weeks)", iTextUtil.getFontModelPricingTitle()))); } if (pricing.isMale()) { pricingTable.addCell(cellH(new Paragraph("Male", iTextUtil.getFontModelPricingTitle()))); } if (pricing.isFemale()) { pricingTable.addCell(cellH(new Paragraph("Female", iTextUtil.getFontModelPricingTitle()))); } boolean invert = false; for (Line line : pricing.getLines()) { if (pricing.isQuantities()) { pricingTable.addCell( cellD(new Paragraph(line.getQuantity(), iTextUtil.getFontModelPricingData()), invert)); } if (pricing.isAge()) { pricingTable .addCell(cellD(new Paragraph(line.getAge(), iTextUtil.getFontModelPricingData()), invert)); } if (pricing.isMale()) { pricingTable .addCell(cellD(new Paragraph(line.getMale(), iTextUtil.getFontModelPricingData()), invert)); } if (pricing.isFemale()) { pricingTable.addCell( cellD(new Paragraph(line.getFemale(), iTextUtil.getFontModelPricingData()), invert)); } invert = !invert; } if (!StringUtils.isEmpty(pricing.getMessage())) { pricingTable.addCell(cell(new Paragraph(pricing.getMessage(), iTextUtil.getFontModelPricingMessage()), pricing.getNumberOfHeaderItems())); } pricingTable.addCell(cell(new Paragraph(" "), pricing.getNumberOfHeaderItems())); return pricingTable; }
From source file:be.thomasmore.controller.PdfController.java
public void createPdfKlas() { Map<String, String> params = FacesContext.getCurrentInstance().getExternalContext() .getRequestParameterMap();//from w ww .ja va 2s . com String KlasId = params.get("klasId"); int id = Integer.parseInt(KlasId); Document document = new Document(); Klas klas = service.getKlas(id); List<Klastest> klastesten = klas.getKlastestList(); List<Test> testen = new ArrayList<Test>(); HttpServletResponse res = (HttpServletResponse) FacesContext.getCurrentInstance().getExternalContext() .getResponse(); res.setHeader("Content-Disposition", "attachement; filename=" + klas.getNummer() + "-resultaten.pdf"); res.setContentType("application/pdf"); try { PdfWriter.getInstance(document, res.getOutputStream()); document.open(); Font font = FontFactory.getFont("Calibri"); Font fontbold = FontFactory.getFont("Calibri", Font.BOLD); PdfPTable table = new PdfPTable(3); // 3 columns. PdfPCell cell1 = new PdfPCell(new Paragraph("Vak", font)); PdfPCell cell2 = new PdfPCell(new Paragraph("Student", font)); PdfPCell cell3 = new PdfPCell(new Paragraph("Behaald", font)); table.addCell(cell1); table.addCell(cell2); table.addCell(cell3); for (Klastest klastest : klastesten) { Test test = klastest.getTestId(); testen.add(service.getTest(test.getId())); } for (Test test : testen) { List<Score> scores = test.getScoreList(); Vak vak = test.getVakId(); for (Score score : scores) { Student student = score.getStudentId(); PdfPCell cellVak = new PdfPCell(new Paragraph(vak.getNaam(), font)); PdfPCell cellStudent = new PdfPCell(new Paragraph(student.getVoornaam(), font)); PdfPCell cellScore = new PdfPCell(new Paragraph(score.getScore().toString(), font)); table.addCell(cellVak); table.addCell(cellStudent); table.addCell(cellScore); } } document.add(new Phrase("Klas: ", font)); document.add(new Phrase(klas.getNummer(), font)); document.add(table); document.close(); } catch (Exception e) { } }
From source file:be.thomasmore.controller.PdfController.java
public void createPdfTest() { Map<String, String> params = FacesContext.getCurrentInstance().getExternalContext() .getRequestParameterMap();// ww w . ja va2 s.c o m String KlasId = params.get("klasId3"); String TestId = params.get("testId"); int klasId = Integer.parseInt(KlasId); int id = Integer.parseInt(TestId); Document document = new Document(); Test test = service.getTest(id); List<Score> scores = test.getScoreList(); Klas klas = service.getKlas(klasId); Vak vak = test.getVakId(); HttpServletResponse res = (HttpServletResponse) FacesContext.getCurrentInstance().getExternalContext() .getResponse(); res.setHeader("Content-Disposition", "attachement; filename=" + test.getBeschrijving() + "-resultaten.pdf"); res.setContentType("application/pdf"); try { PdfWriter.getInstance(document, res.getOutputStream()); document.open(); Font font = FontFactory.getFont("Calibri"); Font fontbold = FontFactory.getFont("Calibri", Font.BOLD); PdfPTable table = new PdfPTable(3); // 3 columns. PdfPCell cell1 = new PdfPCell(new Paragraph("Test", font)); PdfPCell cell2 = new PdfPCell(new Paragraph("Student", font)); PdfPCell cell3 = new PdfPCell(new Paragraph("Score", font)); table.addCell(cell1); table.addCell(cell2); table.addCell(cell3); for (Score score : scores) { Student student = score.getStudentId(); PdfPCell cellTest = new PdfPCell(new Paragraph(test.getBeschrijving(), font)); PdfPCell cellStudent = new PdfPCell(new Paragraph(student.getVoornaam(), font)); PdfPCell cellScore = new PdfPCell(new Paragraph(score.getScore().toString())); table.addCell(cellTest); table.addCell(cellStudent); table.addCell(cellScore); } document.add(new Phrase("Klas: ", font)); document.add(new Phrase(klas.getNummer(), font)); document.add(new Phrase(" Vak: ", font)); document.add(new Phrase(vak.getNaam(), font)); document.add(table); document.close(); } catch (Exception e) { } }
From source file:be.thomasmore.controller.PdfController.java
public void createPdfVak() { Map<String, String> params = FacesContext.getCurrentInstance().getExternalContext() .getRequestParameterMap();/*from www . j av a2s . c o m*/ String KlasId = params.get("klasId2"); String VakId = params.get("vakId"); int klasId = Integer.parseInt(KlasId); int id = Integer.parseInt(VakId); Document document = new Document(); Vak vak = service.getVak(id); List<Test> testen = vak.getTestList(); Klas klas = service.getKlas(klasId); HttpServletResponse res = (HttpServletResponse) FacesContext.getCurrentInstance().getExternalContext() .getResponse(); res.setHeader("Content-Disposition", "attachement; filename=" + vak.getNaam() + "-resultaten.pdf"); res.setContentType("application/pdf"); try { PdfWriter.getInstance(document, res.getOutputStream()); document.open(); Font font = FontFactory.getFont("Calibri"); Font fontbold = FontFactory.getFont("Calibri", Font.BOLD); PdfPTable table = new PdfPTable(3); // 3 columns. PdfPCell cell1 = new PdfPCell(new Paragraph("Test", font)); PdfPCell cell2 = new PdfPCell(new Paragraph("Student", font)); PdfPCell cell3 = new PdfPCell(new Paragraph("Score", font)); table.addCell(cell1); table.addCell(cell2); table.addCell(cell3); for (Test test : testen) { List<Score> scores = test.getScoreList(); for (Score score : scores) { Student student = score.getStudentId(); PdfPCell cellTest = new PdfPCell(new Paragraph(test.getBeschrijving(), font)); PdfPCell cellStudent = new PdfPCell(new Paragraph(student.getVoornaam(), font)); PdfPCell cellScore = new PdfPCell(new Paragraph(score.getScore().toString())); table.addCell(cellTest); table.addCell(cellStudent); table.addCell(cellScore); } } document.add(new Phrase("Klas: ", font)); document.add(new Phrase(klas.getNummer(), font)); document.add(new Phrase(" Vak: ", font)); document.add(new Phrase(vak.getNaam(), font)); document.add(table); document.close(); } catch (Exception e) { } }
From source file:be.thomasmore.controller.PdfController.java
public void createPdfStudent() { Map<String, String> params = FacesContext.getCurrentInstance().getExternalContext() .getRequestParameterMap();/*from ww w .jav a 2 s .c o m*/ String StudentId = params.get("studentId"); int id = Integer.parseInt(StudentId); Document document = new Document(); Student student = service.getStudent(id); List<Score> scores = student.getScoreList(); Klas klas = student.getKlasId(); HttpServletResponse res = (HttpServletResponse) FacesContext.getCurrentInstance().getExternalContext() .getResponse(); res.setHeader("Content-Disposition", "attachement; filename=" + student.getNaam() + student.getVoornaam() + "-resultaten.pdf"); res.setContentType("application/pdf"); try { PdfWriter.getInstance(document, res.getOutputStream()); document.open(); Font font = FontFactory.getFont("Calibri"); PdfPTable table = new PdfPTable(3); // 3 columns. PdfPCell cell1 = new PdfPCell(new Paragraph("Vak", font)); PdfPCell cell2 = new PdfPCell(new Paragraph("Test", font)); PdfPCell cell3 = new PdfPCell(new Paragraph("Score", font)); table.addCell(cell1); table.addCell(cell2); table.addCell(cell3); for (Score score : scores) { Test test = score.getTestId(); PdfPCell cellVak = new PdfPCell(new Paragraph(test.getVakId().getNaam(), font)); PdfPCell cellTest = new PdfPCell(new Paragraph(test.getBeschrijving(), font)); PdfPCell cellScore = new PdfPCell(new Paragraph(score.getScore().toString())); table.addCell(cellVak); table.addCell(cellTest); table.addCell(cellScore); } document.add(new Phrase("Student: ", font)); document.add(new Phrase((student.getNaam() + " " + student.getVoornaam()), font)); document.add(new Phrase("Klas: ", font)); document.add(new Phrase(klas.getNummer(), font)); document.add(table); document.close(); } catch (Exception e) { } }
From source file:be.zenodotus.creatie.GeneratePDF.java
License:Open Source License
public String vakantieAfdruk(Context context, String name, int jaar) { this.context = context; PdfWriter w = null;/*from w ww. j av a2 s . c o m*/ Document d = new Document(PageSize.A4.rotate(), 5, 5, 10, 10); d.setPageCount(3); String fileName = name; String file = name; GregorianCalendar datum = new GregorianCalendar(); datum.set(GregorianCalendar.YEAR, jaar); String[] maanden = { "Januari", "Februari", "Maart", "April", "Mei", "Juni", "Juli", "Augustus", "September", "Oktober", "November", "December" }; int[] dagen = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; VerlofDao dao = new VerlofDao(context); FeestdagDao feestdagDao = new FeestdagDao(context); WerkdagDao werkdagDao = new WerkdagDao(context); File folder = new File(context.getFilesDir(), "pdfs"); folder.mkdirs(); if (datum.isLeapYear(jaar)) { dagen[1] = 29; } File temp = null; temp = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS), "Jacqueline" + jaar + ".pdf"); fileName = temp.toString(); try { dao.open(); ArrayList<Verlof> verloflijst = dao.getAlleVerlovenPerJaar(jaar); w = PdfWriter.getInstance(d, new FileOutputStream(temp)); d.open(); d.addAuthor("Jacqueline Vandenbroecke"); d.addCreationDate(); d.addCreator("Verlofplanner"); d.addTitle("Vakantie " + jaar + " van Jacqueline Vandenbroecke"); Font standaard = FontFactory.getFont(FontFactory.HELVETICA, 8); Font standaardBold = FontFactory.getFont(FontFactory.HELVETICA, 8, Font.BOLD); Paragraph gegeven = new Paragraph("Jacqueline Vandenbroecke Verlof " + jaar + "\n", standaardBold); gegeven.setAlignment(Paragraph.ALIGN_CENTER); d.add(gegeven); for (int paginas = 0; paginas < 2; paginas++) { int aantal = 0; if (paginas == 1) { d.newPage(); aantal = 6; } PdfPTable table = new PdfPTable(6); for (int i = aantal; i < (aantal + 6); i++) { PdfPCell cell = new PdfPCell(new Paragraph(maanden[i], standaardBold)); cell.setBorder(1); table.addCell(cell); } int dag = 1; int k = aantal; for (int i = aantal; i < (aantal + 6); i++) { for (int j = 0; j < 32; j++) { if (k > ((aantal + 6) - 1)) { k = aantal; dag++; } if (dag > dagen[k]) { PdfPCell cell = new PdfPCell(new Paragraph("", standaard)); table.addCell(cell); k++; } else { SimpleDateFormat formatterDag = new SimpleDateFormat("dd"); SimpleDateFormat formatterWeek = new SimpleDateFormat("EEE"); datum.set(jaar, k, dag); PdfPTable dagTabel = new PdfPTable(4); PdfPCell cellDag = new PdfPCell( new Paragraph(formatterDag.format(datum.getTime()), standaard)); PdfPCell cellWeek = new PdfPCell( new Paragraph(formatterWeek.format(datum.getTime()), standaard)); ArrayList<Verlof> verlof = new ArrayList<Verlof>(); for (int z = 0; z < verloflijst.size(); z++) { if (((verloflijst.get(z).getDag() + 1) == dag) && (verloflijst.get(z).getMaand() == k)) { verlof.add(verloflijst.get(z)); } } feestdagDao.open(); Feestdag feestdag = feestdagDao.getFeestdag(jaar, datum.get(GregorianCalendar.MONTH), datum.get(GregorianCalendar.DATE)); feestdagDao.close(); werkdagDao.open(); java.util.List<Werkdag> weekend = werkdagDao.getWeekend(); werkdagDao.close(); String Verlof = ""; String uur = ""; if (verlof.size() > 0) { if (verlof.size() > 1) { Verlof = verlof.get(0).getVerlofsoort() + "\n" + verlof.get(1).getVerlofsoort(); uur = verlof.get(0).getUrental() + "\n" + verlof.get(1).getUrental(); } else { Verlof = verlof.get(0).getVerlofsoort(); uur = verlof.get(0).getUrental(); } } PdfPCell cellVerlof = new PdfPCell(new Paragraph(Verlof, standaard)); PdfPCell uren = new PdfPCell(new Paragraph(uur, standaard)); if (verlof.size() > 0) { BaseColor kleur = new BaseColor(Color.GRAY); cellVerlof.setBackgroundColor(kleur); uren.setBackgroundColor(kleur); cellDag.setBackgroundColor(kleur); cellWeek.setBackgroundColor(kleur); } for (int z = 0; z < weekend.size(); z++) { if ((formatterWeek.format(datum.getTime())).equals(weekend.get(z).getDag())) { BaseColor kleur = new BaseColor(Color.LTGRAY); cellVerlof.setBackgroundColor(kleur); uren.setBackgroundColor(kleur); cellDag.setBackgroundColor(kleur); cellWeek.setBackgroundColor(kleur); } } if (feestdag != null) { BaseColor kleur = new BaseColor(Color.GREEN); uren.setBackgroundColor(kleur); cellVerlof.setBackgroundColor(kleur); uren.setBackgroundColor(kleur); cellDag.setBackgroundColor(kleur); cellWeek.setBackgroundColor(kleur); } dagTabel.addCell(cellDag); dagTabel.addCell(cellWeek); dagTabel.addCell(cellVerlof); dagTabel.addCell(uren); table.addCell(dagTabel); k++; } } } d.add(table); dao.close(); } } catch (Exception ex) { ex.printStackTrace(); } finally { d.close(); w.close(); } return fileName; }