List of usage examples for com.lowagie.text Font Font
public Font(int family, float size)
From source file:fr.aliasource.webmail.server.export.ConversationExporter.java
License:GNU General Public License
private Chunk getRecipientValue(List<EmailAddress> recipients) { Chunk recipientsChunk = null;/* ww w .ja va 2 s .co m*/ if (recipients != null && !recipients.isEmpty()) { StringBuilder recipientsText = new StringBuilder(200); formatRecipients(recipientsText, recipients, false); recipientsChunk = new Chunk(recipientsText.toString(), new Font(Font.HELVETICA, 9)); recipientsChunk.setTextRise(15.0f); } return recipientsChunk; }
From source file:ispyb.client.biosaxs.pdf.DataAcquisitionPDFReport.java
License:Open Source License
private Font getFont(String baseFont) { BaseFont bf = null;// w w w .j av a 2s .co m Font font; try { bf = BaseFont.createFont(baseFont.toString(), FONTS[0][1], BaseFont.EMBEDDED); } catch (DocumentException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } font = new Font(bf, 6); return font; }
From source file:ispyb.client.biosaxs.pdf.DataAcquisitionPDFReport.java
License:Open Source License
private Font getFont() { BaseFont bf = null;//from w ww .j a v a 2s .co m Font font; try { bf = BaseFont.createFont(FONTS[0][0], FONTS[0][1], BaseFont.EMBEDDED); } catch (DocumentException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } font = new Font(bf, 6); return font; }
From source file:ispyb.client.biosaxs.pdf.DataAcquisitionPDFReport.java
License:Open Source License
private ByteArrayOutputStream exportAsPdf(Experiment3VO experiment, List<Buffer3VO> buffers, Proposal3VO proposal) throws Exception { Document document = new Document(PageSize.A4.rotate(), 10, 10, 20, 20); document.addTitle("exportSamplesView"); ByteArrayOutputStream baos = new ByteArrayOutputStream(); PdfWriter.getInstance(document, baos); HeaderFooter header = new HeaderFooter( new Phrase(proposal.getTitle() + " " + proposal.getCode() + proposal.getNumber()), false); header.setAlignment(Element.ALIGN_CENTER); header.getBefore().getFont().setSize(8); HeaderFooter footer = new HeaderFooter(new Phrase("Page n."), true); footer.setAlignment(Element.ALIGN_RIGHT); footer.setBorderWidth(1);// w ww .jav a 2 s . co m footer.getBefore().getFont().setSize(6); document.setHeader(header); document.setFooter(footer); document.open(); BaseFont bf = BaseFont.createFont(FONTS[0][0], FONTS[0][1], BaseFont.EMBEDDED); Font font = new Font(bf, 6); document.add(new Paragraph("Data Acquisition: " + experiment.getName(), font)); document.add(new Paragraph("Type: " + experiment.getType(), font)); document.add(new Paragraph("Date: " + experiment.getCreationDate(), font)); document.add(new Paragraph("Proposal: " + proposal.getCode() + proposal.getNumber(), font)); document.add(new Paragraph("Title: " + proposal.getTitle(), font)); document.add(new Paragraph(" ")); document.add(new Paragraph("Measurements", PdfRtfExporter.FONT_DOC_BOLD)); document.add(new Paragraph(" ")); document.add(this.getMeasurementTable(experiment, buffers)); document.newPage(); document.add(new Paragraph(" ")); document.add(new Paragraph("Analysis", PdfRtfExporter.FONT_DOC_BOLD)); document.add(new Paragraph(" ")); document.add(this.getAnalysis(experiment, buffers)); document.newPage(); document.add(this.getImageTable(experiment, buffers)); document.close(); return baos; }
From source file:ispyb.common.util.export.PdfExporterSample.java
License:Open Source License
/** * Exports the file for viewSample for shipment * //w ww. j ava2 s. c om * @return * @throws Exception */ public ByteArrayOutputStream exportAsPdf() throws Exception { // create simple doc and write to a ByteArrayOutputStream Document document = new Document(PageSize.A4.rotate(), 20, 20, 20, 20); document.addTitle("exportSamplesView"); ByteArrayOutputStream baos = new ByteArrayOutputStream(); PdfWriter.getInstance(document, baos); HeaderFooter header; // header + footer if (viewName != null) header = new HeaderFooter(new Phrase("Samples for Proposal: " + proposalDesc + " --- " + viewName), false); else header = new HeaderFooter(new Phrase("Samples for Proposal: " + proposalDesc), false); header.setAlignment(Element.ALIGN_CENTER); header.setBorderWidth(1); header.getBefore().getFont().setSize(8); HeaderFooter footer = new HeaderFooter(new Phrase("Page n."), true); footer.setAlignment(Element.ALIGN_RIGHT); footer.setBorderWidth(1); footer.getBefore().getFont().setSize(6); document.setHeader(header); document.setFooter(footer); document.open(); if (aList.isEmpty()) { document.add(new Paragraph("There is no samples in this report")); document.close(); return baos; } // Create first table for samples int NumColumns = 19; PdfPTable table = new PdfPTable(NumColumns); int headerwidths[] = { 6, 6, 6, 6, 6, 4, 6, 4, 4, 4, 4, 4, 4, 8, 5, 5, 5, 10, 6 }; // percentage table.setWidths(headerwidths); table.setWidthPercentage(100); // percentage table.getDefaultCell().setPadding(3); table.getDefaultCell().setBorderWidth(1); table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER); // header PdfPCell cell = new PdfPCell(); table.addCell(new Paragraph("Protein", new Font(Font.HELVETICA, 8))); table.addCell(new Paragraph("Sample name", new Font(Font.HELVETICA, 8))); table.addCell(new Paragraph("Smp code", new Font(Font.HELVETICA, 8))); table.addCell(new Paragraph("Dewar", new Font(Font.HELVETICA, 8))); table.addCell(new Paragraph("Container", new Font(Font.HELVETICA, 8))); table.addCell(new Paragraph("Loc. in cont.", new Font(Font.HELVETICA, 8))); table.addCell(new Paragraph("Space group", new Font(Font.HELVETICA, 8))); table.addCell(new Paragraph("Cell a", new Font(Font.HELVETICA, 8))); table.addCell(new Paragraph("Cell b", new Font(Font.HELVETICA, 8))); table.addCell(new Paragraph("Cell c", new Font(Font.HELVETICA, 8))); table.addCell(new Paragraph("Cell alpha", new Font(Font.HELVETICA, 8))); table.addCell(new Paragraph("Cell beta", new Font(Font.HELVETICA, 8))); table.addCell(new Paragraph("Cell gamma", new Font(Font.HELVETICA, 8))); cell = new PdfPCell(new Paragraph("Crystal comments", new Font(Font.HELVETICA, 8))); table.addCell(cell); table.addCell(new Paragraph("Already observed resol.", new Font(Font.HELVETICA, 8))); table.addCell(new Paragraph("Required resol.", new Font(Font.HELVETICA, 8))); table.addCell(new Paragraph("Min. resol.", new Font(Font.HELVETICA, 8))); table.addCell(new Paragraph("Sample comments", new Font(Font.HELVETICA, 8))); table.addCell(new Paragraph("Sample status", new Font(Font.HELVETICA, 8))); table.setHeaderRows(1); // this is the end of the table header table.getDefaultCell().setBorderWidth(1); DecimalFormat df1 = new DecimalFormat("#####0.0"); DecimalFormat df2 = new DecimalFormat("#####0.00"); Iterator it = aList.iterator(); int i = 1; String currentContainer = "next"; String nextContainer = "next"; while (it.hasNext()) { table.getDefaultCell().setGrayFill(0.99f); if (i % 2 == 1) { table.getDefaultCell().setGrayFill(0.9f); } BLSample3VO samplefv = (BLSample3VO) it.next(); LOG.debug("table of datacollections pdf " + samplefv.getBlSampleId()); if (samplefv.getContainerVO() != null && samplefv.getContainerVO().getCode() != null) nextContainer = samplefv.getContainerVO().getCode(); else nextContainer = "next"; // in the case of view sorted by dewar/container, we add a page break afetr each container if (sortView.equals("2") && !currentContainer.equals(nextContainer)) { document.add(table); table.deleteBodyRows(); document.newPage(); } if (samplefv.getCrystalVO().getProteinVO().getAcronym() != null) table.addCell(new Paragraph(samplefv.getCrystalVO().getProteinVO().getAcronym(), new Font(Font.HELVETICA, 8))); else table.addCell(""); if (samplefv.getName() != null) table.addCell(new Paragraph(samplefv.getName(), new Font(Font.HELVETICA, 8))); else table.addCell(""); if (samplefv.getCode() != null) table.addCell(new Paragraph(samplefv.getCode(), new Font(Font.HELVETICA, 8))); else table.addCell(""); if (samplefv.getContainerVO() != null && samplefv.getContainerVO().getDewarVO() != null && samplefv.getContainerVO().getDewarVO().getCode() != null) table.addCell(new Paragraph(samplefv.getContainerVO().getDewarVO().getCode(), new Font(Font.HELVETICA, 8))); else table.addCell(""); if (samplefv.getContainerVO() != null && samplefv.getContainerVO().getCode() != null) { currentContainer = samplefv.getContainerVO().getCode(); table.addCell(new Paragraph(currentContainer, new Font(Font.HELVETICA, 8))); } else { currentContainer = "current"; table.addCell(""); } if (samplefv.getLocation() != null) table.addCell(new Paragraph(samplefv.getLocation(), new Font(Font.HELVETICA, 8))); else table.addCell(""); if (samplefv.getCrystalVO().getSpaceGroup() != null) table.addCell(new Paragraph(samplefv.getCrystalVO().getSpaceGroup(), new Font(Font.HELVETICA, 8))); else table.addCell(""); if (samplefv.getCrystalVO().getCellA() != null) table.addCell( new Paragraph(df1.format(samplefv.getCrystalVO().getCellA()), new Font(Font.HELVETICA, 8))); else table.addCell(""); if (samplefv.getCrystalVO().getCellB() != null) table.addCell( new Paragraph(df1.format(samplefv.getCrystalVO().getCellB()), new Font(Font.HELVETICA, 8))); else table.addCell(""); if (samplefv.getCrystalVO().getCellC() != null) table.addCell( new Paragraph(df1.format(samplefv.getCrystalVO().getCellC()), new Font(Font.HELVETICA, 8))); else table.addCell(""); if (samplefv.getCrystalVO().getCellAlpha() != null) table.addCell(new Paragraph(df1.format(samplefv.getCrystalVO().getCellAlpha()), new Font(Font.HELVETICA, 8))); else table.addCell(""); if (samplefv.getCrystalVO().getCellBeta() != null) table.addCell(new Paragraph(df1.format(samplefv.getCrystalVO().getCellBeta()), new Font(Font.HELVETICA, 8))); else table.addCell(""); if (samplefv.getCrystalVO().getCellGamma() != null) table.addCell(new Paragraph(df1.format(samplefv.getCrystalVO().getCellGamma()), new Font(Font.HELVETICA, 8))); else table.addCell(""); if (samplefv.getCrystalVO().getComments() != null) table.addCell(new Paragraph(samplefv.getCrystalVO().getComments(), new Font(Font.HELVETICA, 8))); else table.addCell(""); if (samplefv.getDiffractionPlanVO() != null && samplefv.getDiffractionPlanVO().getObservedResolution() != null) { table.addCell(new Paragraph(df2.format(samplefv.getDiffractionPlanVO().getObservedResolution()), new Font(Font.HELVETICA, 8))); } else if (samplefv.getCrystalVO().getDiffractionPlanVO() != null && samplefv.getCrystalVO().getDiffractionPlanVO().getObservedResolution() != null) table.addCell(new Paragraph( df2.format(samplefv.getCrystalVO().getDiffractionPlanVO().getObservedResolution()), new Font(Font.HELVETICA, 8))); else table.addCell(""); if (samplefv.getDiffractionPlanVO() != null && samplefv.getDiffractionPlanVO().getRequiredResolution() != null) { table.addCell(new Paragraph(df2.format(samplefv.getDiffractionPlanVO().getRequiredResolution()), new Font(Font.HELVETICA, 8))); } else if (samplefv.getCrystalVO().getDiffractionPlanVO() != null && samplefv.getCrystalVO().getDiffractionPlanVO().getRequiredResolution() != null) table.addCell(new Paragraph( df2.format(samplefv.getCrystalVO().getDiffractionPlanVO().getRequiredResolution()), new Font(Font.HELVETICA, 8))); else table.addCell(""); if (samplefv.getDiffractionPlanVO() != null && samplefv.getDiffractionPlanVO().getMinimalResolution() != null) { table.addCell(new Paragraph(df2.format(samplefv.getDiffractionPlanVO().getMinimalResolution()), new Font(Font.HELVETICA, 8))); } else if (samplefv.getCrystalVO().getDiffractionPlanVO() != null && samplefv.getCrystalVO().getDiffractionPlanVO().getMinimalResolution() != null) table.addCell(new Paragraph( df2.format(samplefv.getCrystalVO().getDiffractionPlanVO().getMinimalResolution()), new Font(Font.HELVETICA, 8))); else table.addCell(""); if (samplefv.getComments() != null && samplefv.getComments() != "") table.addCell(new Paragraph(samplefv.getComments(), new Font(Font.HELVETICA, 8))); else table.addCell(""); if (samplefv.getBlSampleStatus() != null) table.addCell(new Paragraph(samplefv.getBlSampleStatus(), new Font(Font.HELVETICA, 8))); else table.addCell(""); if (i % 2 == 1) { table.getDefaultCell().setGrayFill(0.0f); } i++; } document.add(table); document.close(); return baos; }
From source file:lt.bsprendimai.ddesk.pdf.PDFTicket.java
License:Apache License
public byte[] writePage() throws Exception { ByteArrayOutputStream bout = new ByteArrayOutputStream(); try {// w w w . ja va 2 s . com logo = Image.getInstance(root.getAbsolutePath() + "/logo.gif"); logo.setAlignment(Image.ALIGN_LEFT); } catch (Exception exc) { exc.printStackTrace(); } baseArial = BaseFont.createFont(root.getAbsolutePath() + "/objects/arial.ttf", BaseFont.CP1257, BaseFont.EMBEDDED); Document doc = new Document(PageSize.A4, 56.5354331f, 22.6771654f, 28.3464567f, 25.0f); PdfWriter.getInstance(doc, bout); doc.open(); logo.setAbsolutePosition(28.3464567f, doc.getPageSize().height() - logo.height() - 25.0f); doc.add(logo); Paragraph pg = new Paragraph(sdf.format(new Date()), new Font(baseArial, 10)); pg.setAlignment(Element.ALIGN_RIGHT); doc.add(pg); doc.add(new Phrase("\n\n\n")); writeClientInfo(doc); writeTicketInfo(doc); writeJobInfo(doc); writeWorkerInfo(doc); doc.close(); return bout.toByteArray(); }
From source file:lt.bsprendimai.ddesk.pdf.PDFTicket.java
License:Apache License
private void writeClientInfo(Document doc) throws Exception { PdfPTable tb = new PdfPTable(2); tb.setWidthPercentage(100.0f);//from w w w. ja v a2 s. co m tb.setSpacingAfter(20.0f); PdfPCell cl = new PdfPCell( new Phrase(this.client.getName() + "\n" + this.client.getAdress(), new Font(baseArial, 10))); tb.addCell(cl); cl = new PdfPCell(new Phrase(this.we.getName() + "\n" + this.we.getAdress(), new Font(baseArial, 10))); tb.addCell(cl); doc.add(tb); }
From source file:lt.bsprendimai.ddesk.pdf.PDFTicket.java
License:Apache License
private void writeWorkerInfo(Document doc) throws Exception { PdfPTable tb = new PdfPTable(2); tb.setWidthPercentage(100.0f);//from w w w . ja v a 2s .c o m tb.setSpacingBefore(8.0f); tb.setSpacingAfter(8.0f); PdfPCell cl; cl = new PdfPCell(new Phrase("Atsakingas asmuo: " + me.getName(), new Font(baseArial, 10))); cl.setColspan(2); tb.addCell(cl); cl = new PdfPCell(new Phrase("vykdymo data: " + timeFormat(tt.getDateClosed()), new Font(baseArial, 10))); tb.addCell(cl); if (tt.getWorktime() != null) { cl = new PdfPCell(new Phrase("Darbo valandos:" + tt.getWorktime(), new Font(baseArial, 10))); tb.addCell(cl); } else { cl = new PdfPCell(new Phrase("Darbo valandos: ", new Font(baseArial, 10))); tb.addCell(cl); } doc.add(tb); tb = new PdfPTable(2); tb.setWidthPercentage(100.0f); tb.setSpacingBefore(50.0f); cl = new PdfPCell(new Phrase("Kliento paraas\n\n\n\n", new Font(baseArial, 10))); cl.setBorder(0); tb.addCell(cl); cl = new PdfPCell(new Phrase("Uduot atliks darbuotojas\n\n\n\n", new Font(baseArial, 10))); cl.setBorder(0); tb.addCell(cl); doc.add(tb); }
From source file:mx.dr.util.report.impl.PdfService.java
License:Open Source License
/** * write a label in pdf document.//w w w . j av a2s. c o m * <br/> * escribe una etiqueta en el documento pdf. * @param doc pdf document / documento pdf. * @param dto object that encompasses the values of the labels to be placed in the document / objeto que engloba los valores de las etiquetas que se colocaran en el documento. * @param offset jump on the Y axis to be given before placing the tag in the document / salto en el eje Y que se dara antes de colocar la etiqueta en el documento. * @param table container table if applicable / contenedor de tabla si es que aplica. * @throws Exception If an error occurs / si ocurre algun error. */ public void estampaEtiqueta(Document doc, Object dto, Float offset, PdfPTable table) throws Exception { List<Field> fields = new ArrayList<Field>(); for (Field m : dto.getClass().getDeclaredFields()) { m.setAccessible(true); if (m.getAnnotation(DRPdfLabel.class) != null) { fields.add(m); } } Collections.sort(fields, new Comparator<Field>() { public int compare(Field o1, Field o2) { DRPdfLabel etiqueta1 = o1.getAnnotation(DRPdfLabel.class); DRPdfLabel etiqueta2 = o2.getAnnotation(DRPdfLabel.class); String uno = int2String(etiqueta1.y()) + "." + int2String(etiqueta1.order()); String dos = int2String(etiqueta2.y()) + "." + int2String(etiqueta2.order()); return uno.compareTo(dos); } private String int2String(int num) { if (num < 10) { return "0" + num; } else { return String.valueOf(num); } } }); DRPdfLabel etiqueta; DRPdfTable etiquetaTabla; int lineaActual = 0; Paragraph pantagram = null; StringBuffer sb = null; Font font; Object valor; String label; DRPdfImage img; int residuo; int adicional = 0; for (Field m : fields) { etiqueta = m.getAnnotation(DRPdfLabel.class); img = m.getAnnotation(DRPdfImage.class); valor = m.get(dto); if (valor != null && valor instanceof List) { etiquetaTabla = m.getAnnotation(DRPdfTable.class); PdfPTable tableDance = null; if (etiquetaTabla != null) { tableDance = new PdfPTable(etiquetaTabla.colsPercentage()); tableDance.setSpacingBefore(etiqueta.offset()); for (String c : etiquetaTabla.columnLabels()) { tableDance.addCell(c); } } if (pantagram != null) { doc.add(pantagram); pantagram = null; } for (int i = 0; i < ((List) valor).size(); i++) { if (i == 0 && etiqueta.offset() > 0) { estampaEtiqueta(doc, ((List) valor).get(i), etiqueta.offset(), tableDance); } else { estampaEtiqueta(doc, ((List) valor).get(i), null, tableDance); } } if (etiquetaTabla != null) { doc.add(tableDance); } } else if (img != null) { /* File file = new File(IMGDIR + valor); FileInputStream inImg = new FileInputStream(file); byte[] b=new byte[(int)file.length()]; inImg.read(b);*/ Image ima = Image.getInstance(IMGDIR + valor); //System.out.println(ima.getPlainWidth()); ima.scaleAbsoluteWidth(img.width()); //System.out.println(ima.getScaledWidth()); ima.scaleAbsoluteHeight(ima.getScaledWidth()); ima.setAlignment(img.style()); ima.setAbsolutePosition(img.x(), img.y()); doc.add(ima); } else if (table != null) { PdfPCell cerda = null; label = value2String(valor); residuo = etiqueta.length() - label.length(); label = etiqueta.length() > 0 && residuo < 0 ? label.substring(0, etiqueta.length()) : label; DRPdfColumn col = m.getAnnotation(DRPdfColumn.class); if (col != null) { cerda = new PdfPCell(new Paragraph(label)); cerda.setColspan(col.colspan()); table.addCell(cerda); } else { table.addCell(label); } } else { if (lineaActual < etiqueta.y()) { if (pantagram != null) { doc.add(pantagram); } if (offset == null || etiqueta.y() > 1) { if (etiqueta.offset() > 0) { pantagram = new Paragraph(etiqueta.offset()); } else { pantagram = new Paragraph(); } } else { pantagram = new Paragraph(offset); } lineaActual = etiqueta.y(); } if (etiqueta.wspacesBefore() > 0) { sb = new StringBuffer(""); fillEmpty(etiqueta.wspacesBefore(), sb); font = new Font(Font.COURIER, 12); pantagram.add(new Chunk(sb.toString(), font)); } sb = new StringBuffer(""); label = value2String(valor); residuo = etiqueta.length() - label.length(); label = etiqueta.length() > 0 && residuo < 0 ? label.substring(0, etiqueta.length()) : label; if (etiqueta.font().equals(BaseFont.COURIER)) { font = new Font(Font.COURIER, etiqueta.fontSize(), etiqueta.style(), new Color(etiqueta.color()[0], etiqueta.color()[1], etiqueta.color()[2])); adicional = 0; } else { font = FontFactory.getFont(TTFDIR + etiqueta.font(), BaseFont.CP1252, BaseFont.EMBEDDED, etiqueta.fontSize(), etiqueta.style(), new Color(etiqueta.color()[0], etiqueta.color()[1], etiqueta.color()[2])); adicional = label.equals("") ? (residuo / 2) + 1 : 0; } if (etiqueta.length() > 0 && etiqueta.justified().equals(DRPdfLabel.JUSTIFIED.DER) && residuo > 0) { fillEmpty(residuo + adicional, sb); } sb.append(label); if (etiqueta.length() > 0 && etiqueta.justified().equals(DRPdfLabel.JUSTIFIED.IZQ) && residuo > 0) { fillEmpty(residuo + adicional, sb); } pantagram.add(new Chunk(sb.toString(), font)); } } if (pantagram != null) { doc.add(pantagram); } }
From source file:net.algem.contact.TeacherCtrl.java
License:Open Source License
private File getFollowUpAsPDF(String userId, String from, String to) throws IOException, BadElementException, DocumentException { String path = "/tmp/" + "suivi-" + userId + ".pdf"; File f = new File(path); LOGGER.log(Level.INFO, f.getName()); ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); Document document = new Document(PageSize.A4.rotate()); PdfWriter.getInstance(document, byteArrayOutputStream); // Do this BEFORE document.open() document.open();// w w w . j a v a2 s .c o m PdfPTable table = new PdfPTable(10); table.setWidthPercentage(100); table.setWidths(new float[] { 1.1f, 1.2f, 0.6f, 1.5f, 1.5f, 2f, 0.5f, 0.5f, 1.9f, 1.9f }); BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.WINANSI, false); BaseFont bfb = BaseFont.createFont(BaseFont.HELVETICA_BOLD, BaseFont.WINANSI, false); Font normalFont = new Font(bf, 10); Font boldFont = new Font(bfb, 10); String fromLabel = messageSource.getMessage("from.label", null, CTX_LOCALE); String toLabel = messageSource.getMessage("to.label", null, CTX_LOCALE); String prefix = messageSource.getMessage("follow-up.label", null, CTX_LOCALE) + " " + organization.get("name.label"); String period = fromLabel.toLowerCase() + " " + from + " " + toLabel.toLowerCase() + " " + to; PdfPCell headerCell = new PdfPCell(new Phrase(prefix + " " + period, boldFont)); headerCell.setBackgroundColor(Color.LIGHT_GRAY); headerCell.setColspan(10); table.addCell(headerCell); table.addCell(new PdfPCell(new Phrase(messageSource.getMessage("date.label", null, CTX_LOCALE), boldFont))); table.addCell(new PdfPCell(new Phrase(messageSource.getMessage("time.label", null, CTX_LOCALE), boldFont))); table.addCell(new PdfPCell( new Phrase(messageSource.getMessage("time.length.label", null, CTX_LOCALE), boldFont))); table.addCell(new PdfPCell(new Phrase(messageSource.getMessage("room.label", null, CTX_LOCALE), boldFont))); table.addCell( new PdfPCell(new Phrase(messageSource.getMessage("course.label", null, CTX_LOCALE), boldFont))); table.addCell( new PdfPCell(new Phrase(messageSource.getMessage("student.label", null, CTX_LOCALE), boldFont))); String abs = messageSource.getMessage("absence.label", null, CTX_LOCALE); table.addCell(new PdfPCell(new Phrase(abs != null ? abs.substring(0, 3) + "." : "", boldFont))); table.addCell( new PdfPCell(new Phrase(messageSource.getMessage("score.label", null, CTX_LOCALE), boldFont))); table.addCell(new PdfPCell( new Phrase(messageSource.getMessage("individual.logbook.label", null, CTX_LOCALE), boldFont))); table.addCell(new PdfPCell( new Phrase(messageSource.getMessage("collective.comment.label", null, CTX_LOCALE), boldFont))); List<ScheduleElement> items = getFollowUpSchedules(userId, from, to); //LOGGER.log(Level.INFO, items.toString()); for (ScheduleElement e : items) { List<ScheduleRangeElement> ranges = new ArrayList<ScheduleRangeElement>( (Collection<? extends ScheduleRangeElement>) e.getRanges()); for (ScheduleRangeElement r : ranges) { String status = CommonDao.getAbsenceFromNumberStatus(r.getFollowUp().getStatus()); String note = r.getFollowUp().getNote(); String content1 = r.getFollowUp().getContent(); String content2 = e.getFollowUp().getContent(); table.addCell(new Phrase(e.getDateFr().toString(), normalFont)); table.addCell(new Phrase(r.getStart() + "-" + r.getEnd(), normalFont)); table.addCell(new Phrase(new Hour(r.getLength()).toString(), normalFont)); table.addCell(new Phrase(e.getDetail().get("room").getName(), normalFont)); table.addCell(new Phrase(e.getDetail().get("course").getName(), normalFont)); table.addCell(new Phrase(r.getPerson().getFirstName() + " " + r.getPerson().getName(), normalFont)); table.addCell(new Phrase(status, normalFont)); table.addCell(new Phrase(note == null ? "" : note, normalFont)); table.addCell(new Phrase(content1 == null ? "" : content1.replaceAll("[\r\n]", " "), normalFont)); table.addCell(new Phrase(content2 == null ? "" : content2.replaceAll("[\r\n]", " "), normalFont)); } } document.add(table); document.close(); byte[] pdfBytes = byteArrayOutputStream.toByteArray(); Files.write(Paths.get(path), pdfBytes); return f; }