List of usage examples for com.lowagie.text Image setAlignment
public void setAlignment(int alignment)
From source file:ilarkesto.integration.itext.Paragraph.java
License:Open Source License
@Override public Element getITextElement() { com.lowagie.text.Paragraph p = new com.lowagie.text.Paragraph(); float maxSize = 0; for (AParagraphElement element : getElements()) { if (element instanceof TextChunk) { TextChunk textChunk = (TextChunk) element; FontStyle fontStyle = textChunk.getFontStyle(); FontSelector fontSelector = createFontSelector(fontStyle.getFont(), fontStyle); String text = textChunk.getText(); Phrase phrase = fontSelector.process(text); p.add(phrase);/* w w w. ja va 2 s . c om*/ float size = (fontStyle.getSize() * 1.1f) + 1f; if (size > maxSize) maxSize = PdfBuilder.mmToPoints(size); } else if (element instanceof Image) { Image image = (Image) element; com.lowagie.text.Image itextImage; try { itextImage = image.getITextElement(); } catch (Exception ex) { log.warn("Including image failed:", image, ex); continue; } if (image.getAlign() != null) { itextImage.setAlignment(Image.convertAlign(image.getAlign()) | com.lowagie.text.Image.TEXTWRAP); p.add(itextImage); } else { Chunk chunk = new Chunk(itextImage, 0, 0); p.add(chunk); float size = image.getHeight() + 3; if (size > maxSize) maxSize = size; } } else { throw new RuntimeException("Unsupported paragraph element: " + element.getClass().getName()); } } p.setLeading(maxSize); p.setSpacingBefore(PdfBuilder.mmToPoints(spacingTop)); p.setSpacingAfter(PdfBuilder.mmToPoints(spacingBottom)); if (align != null) p.setAlignment(convertAlign(align)); if (height <= 0) return p; // wrap in table PdfPCell cell = new PdfPCell(); cell.setBorder(0); cell.setFixedHeight(PdfBuilder.mmToPoints(height)); cell.addElement(p); PdfPTable table = new PdfPTable(1); table.setWidthPercentage(100); table.addCell(cell); return table; }
From source file:it.eng.spagobi.engines.exporters.ChartExporter.java
License:Mozilla Public License
public File getChartPDF(String uuid, boolean multichart, String orientation) throws Exception { logger.debug("IN"); File tmpFile;/*from w w w. ja va 2 s . c o m*/ try { tmpFile = null; String dir = System.getProperty("java.io.tmpdir"); String path = (new StringBuilder(String.valueOf(dir))).append("/").append(uuid).append(".png") .toString(); File dirF = new File(dir); tmpFile = File.createTempFile("tempPDFExport", ".pdf", dirF); Document pdfDocument = new Document(); PdfWriter docWriter = PdfWriter.getInstance(pdfDocument, new FileOutputStream(tmpFile)); //pdfDocument.open(); if (multichart) { pdfDocument.open(); List images = new ArrayList(); for (int i = 0; i < MAX_NUM_IMG; i++) { String imgName = (new StringBuilder(String.valueOf(path.substring(0, path.indexOf(".png"))))) .append(i).append(".png").toString(); Image png = Image.getInstance(imgName); if (png == null) { break; } images.add(png); } Table table = new Table(images.size()); for (int i = 0; i < images.size(); i++) { Image png = (Image) images.get(i); if (HORIZONTAL_ORIENTATION.equalsIgnoreCase(orientation)) { Cell pngCell = new Cell(png); pngCell.setBorder(0); table.setBorder(0); table.addCell(pngCell); } else { png.setAlignment(5); pdfDocument.add(png); } } pdfDocument.add(table); } else { Image jpg = Image.getInstance(path); float height = jpg.getHeight(); float width = jpg.getWidth(); // if in need to change layout if (width > MAX_WIDTH || height > MAX_HEIGHT) { changeLayout(pdfDocument, jpg, width, height); } pdfDocument.open(); pdfDocument.add(jpg); } pdfDocument.close(); docWriter.close(); logger.debug("OUT"); return tmpFile; } catch (Throwable e) { logger.error("An exception has occured", e); throw new Exception(e); } finally { //tmpFile.delete(); } }
From source file:it.prato.comune.tolomeo.web.TolomeoPrintPDFServlet.java
License:Open Source License
@Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { LogInterface logger = getLogger(request); String titolo = request.getParameter("titolo"); String descrizione = request.getParameter("descrizione"); String scala = request.getParameter("scala"); String mapx = request.getParameter("mapx"); String mapy = request.getParameter("mapy"); //creo URL alla mappa URL urlMappa = new URL(URLDecoder.decode(request.getParameter("urlMappa"), "UTF-8")); URI uriMappa = null;/*from w ww .j av a2 s. co m*/ try { uriMappa = new URI(urlMappa.getProtocol(), null, urlMappa.getHost(), urlMappa.getPort(), urlMappa.getPath(), urlMappa.getQuery() + "&mode=map&scale=" + scala + "&mapxy=" + mapx + "+" + mapy + "&map_size=500 500", null); logger.info("URI di stampa mappa: " + uriMappa); } catch (URISyntaxException e) { logger.error("URI errore di sintassi", e); } Font BOLD15 = new Font(Font.HELVETICA, 15, Font.BOLD); Font FONT12 = new Font(Font.HELVETICA, 12, Font.NORMAL); Font FONT10 = new Font(Font.HELVETICA, 10, Font.NORMAL); Document doc = new Document(); ; PdfWriter pdf = null; Paragraph par = new Paragraph(); try { //creo il PDF response.setContentType("application/pdf"); pdf = PdfWriter.getInstance(doc, response.getOutputStream()); //attributi file doc.addTitle("Mappa di Prato"); doc.addAuthor("Comune di Prato"); doc.open(); //intestazione par.setAlignment(Paragraph.ALIGN_CENTER); print("Comune di Prato", BOLD15, par, doc); print(titolo, FONT10, par, doc); print("", FONT10, par, doc); //mappa Image mappa = Image.getInstance(uriMappa.toURL()); mappa.setAlignment(Image.MIDDLE); mappa.setBorder(Rectangle.BOX); mappa.setBorderWidth(1f); doc.add(mappa); } catch (Exception e) { logger.error("Errore durante la creazione del PDF", e); printErr(doc); } finally { doc.close(); pdf.close(); response.getOutputStream().close(); } }
From source file:jm.seg.frmGeneraPdf.java
License:GNU General Public License
private Image getBarcode(PdfWriter pdfWriter, String codigo) { PdfContentByte cimg = pdfWriter.getDirectContent(); Barcode128 code128 = new Barcode128(); code128.setCode(codigo);/* ww w. j a v a2s . c om*/ code128.setCodeType(Barcode128.CODE128); code128.setTextAlignment(Element.ALIGN_CENTER); Image image = code128.createImageWithBarcode(cimg, null, null); //float scaler = ((document.getPageSize().getWidth() - document.leftMargin() - document.rightMargin() - 0) / image.getWidth()) * 70; //image.scalePercent(scaler); //image.scaleAbsolute(90f, 35f); image.scalePercent(90f); image.setAlignment(Element.ALIGN_CENTER); return image; }
From source file:knop.psfj.exporter.PDFExporter.java
License:Open Source License
/** * Fill report.// w w w .j a va 2 s. co m * * @param report the report * @param writer the writer * @param bead the bead * @param id the id */ public static void fillReport(Document report, PdfWriter writer, BeadFrame bead, int id) { Microscope microscope = bead.getSource().getMicroscope(); ReportSections rs = new ReportSections(); writer.setStrictImageSequence(true); try { /* * report.add(rs.bigTitle("Bead " + id)); * report.add(rs.littleNote(microscope.date)); /* * report.add(rs.title("Profile view:")); ImagePlus img; try { img = * svg.getPanelView(pp.getImagePlus(), SideViewGenerator.MAX_METHOD, * true, true, 5, false, null, 0); } catch (NullPointerException e) * { e.printStackTrace(); return; } float zoom2scaleTo256pxMax = * 25600 / Math.max(img.getWidth(), img.getHeight()); * report.add(rs.imagePlus(img, zoom2scaleTo256pxMax)); * * report.add(rs.title("Microscope infos:")); * report.add(rs.paragraph(microscope.getMicroscopeHeader())); */ id = bead.getId(); String suffix = ""; if (bead.isValid() == false) suffix = " (Rejected)"; if (bead.isValid() && bead.getInvalidityReason() != null) { suffix = " (Rejected from the pair analysis)"; } // Image logo = loadImage("knoplablogo.png"); // report.add(); // currentDocument.add(rs.littleNote(FileUtils.getTodayDate())); double[] resolutions = bead.getResolutions(); // the resolutions extracted from the Bead Spread function are // assigned to // individual variables String resolutionX = microscope.formatDouble(bead.getResolution(0)); String resolutionY = microscope.formatDouble(bead.getResolution(1)); String resolutionZ = microscope.formatDouble(bead.getResolution(2)); // the corrected resolution are calculated by the Microscope Object // (it holds // all the experiment data). String correctedResolutionX = microscope.formatDouble(bead.getCorrectionResolution(Microscope.X)); String correctedResolutionY = microscope.formatDouble(bead.getCorrectionResolution(Microscope.Y)); String correctedResolutionZ = microscope.formatDouble(bead.getCorrectionResolution(Microscope.Z)); String asymmetry = MathUtils.roundToString(bead.getAsymetry(), 3); String theta = MathUtils.roundToString(bead.getThetaInDegrees(), 1) + MathUtils.DEGREE_SYMBOL; String[][] content = { { "FWHM", "min", "max", "z", "Asymmetry", "Theta" }, { "Non corrected", resolutionX, resolutionY, resolutionZ, asymmetry, theta }, { "Corrected", correctedResolutionX, correctedResolutionY, correctedResolutionZ, "", "" }, { "Theoretical", microscope.formatDouble(microscope.getXYTheoreticalResolution()), microscope.formatDouble(microscope.getXYTheoreticalResolution()), microscope.formatDouble(microscope.getZTheoreticalResolution()), "", "" } }; Paragraph header = new Paragraph(); Image sideView = rs.imagePlus(bead.getSideViewImage(), 100); sideView.setAlignment(Image.ALIGN_RIGHT | Image.TEXTWRAP); report.add(sideView); String microscopeId = bead.getSource().getMicroscope().getIdentifier(); if (microscopeId.equals("") == false) microscopeId = String.format(" ( %s )", microscopeId); String date = "Date : " + FileUtils.getTodayDate(); String origin = String.format("\n Origin : %s %s\n Frame size : %d pixels\n", bead.getSource().getImageName(), microscopeId, bead.getWidth()); String shift; String correspondingBead = "\nCorresponding bead : " + ((bead.getAlterEgo() == null) ? "Not found" : "Number " + bead.getAlterEgo().getId() + " in " + bead.getAlterEgo().getSource().getImageName()); String coordinates = "\nCoordinates : " + microscope.formatDouble(bead.getFovX()) + " (x), " + microscope.formatDouble(bead.getFovY()) + " (y), " + microscope.formatDouble(bead.getCentroidZ() * microscope.getCalibration().pixelDepth) + " (z)"; String rejectionReason = (bead.getInvalidityReason() == null ? "" : "\nReason of rejection : " + bead.getInvalidityReason()); if (bead.getAlterEgo() != null) { shift = "\nShift : "; shift += microscope.formatDouble(bead.getDeltaX()); shift += " x " + microscope.formatDouble(bead.getDeltaY()); shift += " x " + microscope.formatDouble(bead.getDeltaZ()); } else { shift = ""; } report.add(rs.title("Bead " + id + suffix)); report.add(rs.paragraph(date + origin + coordinates + correspondingBead + shift + rejectionReason)); // report.add(rs.subtitle("Resolution table:")); report.add(rs.table(content, 100)); int height = 130; ImagePlus xPlot; ImagePlus yPlot; if (bead instanceof BeadFrame2D) { BeadFrame2D bead2D = (BeadFrame2D) bead; xPlot = new ImagePlus("", bead2D.getOverlayWithTheoretical()); yPlot = xPlot; report.add(rs.subtitle("XY profile & fitting parameters : ")); report.add(rs.littleNote("(red : the orignal data, green : the fit, yellow : the two merged)", Paragraph.ALIGN_LEFT)); } else { xPlot = bead.getXplot().getImagePlus(); yPlot = bead.getYplot().getImagePlus(); report.add(rs.subtitle("X profile & fitting parameters:")); } Image image = rs.imagePlus(xPlot, height); image.setAlignment(Image.ALIGN_LEFT | Image.TEXTWRAP); report.add(image); report.add(rs.paragraph(bead.getXParams())); if (bead instanceof BeadFrame2D == false) { report.add(rs.subtitle("Y profile & fitting parameters:")); image = rs.imagePlus(yPlot, height); image.setAlignment(Image.ALIGN_LEFT | Image.TEXTWRAP); report.add(image); report.add(rs.paragraph(bead.getYParams())); } report.add(rs.subtitle("Z profile & fitting parameters:")); image = rs.imagePlus(bead.getZplot().getImagePlus(), height); image.setAlignment(Image.ALIGN_LEFT | Image.TEXTWRAP); report.add(image); report.add(rs.paragraph(bead.getZParams())); if (!microscope.sampleInfos.equals("") || !microscope.comments.equals("")) report.newPage(); if (!microscope.sampleInfos.equals("")) { report.add(rs.title("Sample infos:")); report.add(rs.paragraph(microscope.sampleInfos)); } if (!microscope.comments.equals("")) { report.add(rs.title("Comments:")); report.add(rs.paragraph(microscope.comments)); } // logo.setAlignment(Image.ALIGN_RIGHT | Image.TEXTWRAP); // logo.scalePercent(10); // currentDocument.add(logo); } catch (DocumentException e) { e.printStackTrace(); } System.gc(); }
From source file:mx.dr.util.report.impl.PdfService.java
License:Open Source License
/** * write a label in pdf document./* w w w . j a v a2s. co 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:nl.knaw.dans.common.lang.pdf.ExtendedHtmlWorker.java
License:Apache License
public void startElement(String tag, HashMap h) { if (!tagsSupported.containsKey(tag)) return;/*from www.ja va2s . c o m*/ try { style.applyStyle(tag, h); String follow = (String) FactoryProperties.followTags.get(tag); if (follow != null) { HashMap prop = new HashMap(); prop.put(follow, null); cprops.addToChain(follow, prop); return; } FactoryProperties.insertStyle(h); if (tag.equals("a")) { cprops.addToChain(tag, h); if (currentParagraph == null) currentParagraph = new Paragraph(); stack.push(currentParagraph); currentParagraph = new Paragraph(); return; } if (tag.equals("br")) { if (currentParagraph == null) currentParagraph = new Paragraph(); currentParagraph.add(factoryProperties.createChunk("\n", cprops)); return; } if (tag.equals("font") || tag.equals("span")) { cprops.addToChain(tag, h); return; } if (tag.equals("img")) { String src = (String) h.get("src"); if (src == null) return; cprops.addToChain(tag, h); Image img = null; if (interfaceProps != null) { ImageProvider ip = (ImageProvider) interfaceProps.get("img_provider"); if (ip != null) img = ip.getImage(src, h, cprops, document); if (img == null) { HashMap images = (HashMap) interfaceProps.get("img_static"); if (images != null) { Image tim = (Image) images.get(src); if (tim != null) img = Image.getInstance(tim); } else { if (!src.startsWith("http")) { // relative src references only String baseurl = (String) interfaceProps.get("img_baseurl"); if (baseurl != null) { src = baseurl + src; img = Image.getInstance(src); } } } } } if (img == null) { if (!src.startsWith("http")) { String path = cprops.getProperty("image_path"); if (path == null) path = ""; src = new File(path, src).getPath(); } img = Image.getInstance(src); } String align = (String) h.get("align"); String width = (String) h.get("width"); String height = (String) h.get("height"); String before = cprops.getProperty("before"); String after = cprops.getProperty("after"); if (before != null) img.setSpacingBefore(Float.parseFloat(before)); if (after != null) img.setSpacingAfter(Float.parseFloat(after)); float wp = lengthParse(width, (int) img.getWidth()); float lp = lengthParse(height, (int) img.getHeight()); if (wp > 0 && lp > 0) img.scalePercent(wp > lp ? lp : wp); else if (wp > 0) img.scalePercent(wp); else if (lp > 0) img.scalePercent(lp); img.setWidthPercentage(0); if (align != null) { endElement("p"); int ralign = Image.MIDDLE; if (align.equalsIgnoreCase("left")) ralign = Image.LEFT; else if (align.equalsIgnoreCase("right")) ralign = Image.RIGHT; img.setAlignment(ralign); Img i = null; boolean skip = false; if (interfaceProps != null) { i = (Img) interfaceProps.get("img_interface"); if (i != null) skip = i.process(img, h, cprops, document); } if (!skip) document.add(img); cprops.removeChain(tag); } else { cprops.removeChain(tag); if (currentParagraph == null) currentParagraph = FactoryProperties.createParagraph(cprops); currentParagraph.add(new Chunk(img, 0, 0)); } return; } endElement("p"); if (tag.equals("h1") || tag.equals("h2") || tag.equals("h3") || tag.equals("h4") || tag.equals("h5") || tag.equals("h6")) { if (!h.containsKey("size")) { int v = 7 - Integer.parseInt(tag.substring(1)); h.put("size", Integer.toString(v)); } cprops.addToChain(tag, h); return; } if (tag.equals("ul")) { if (pendingLI) endElement("li"); skipText = true; cprops.addToChain(tag, h); com.lowagie.text.List list = new com.lowagie.text.List(false, 10); list.setListSymbol("\u2022"); String indent = ((String) h.get("indent")); if (indent != null && indent.matches("[0-9]+")) { list.setSymbolIndent(Integer.valueOf(indent)); } stack.push(list); return; } if (tag.equals("ol")) { if (pendingLI) endElement("li"); skipText = true; cprops.addToChain(tag, h); com.lowagie.text.List list = new com.lowagie.text.List(true, 10); String type = ((String) h.get("type")); if (type != null && type.toLowerCase().equals("a")) { list.setLettered(true); list.setNumbered(false); list.setLowercase(type.equals("a")); } String indent = ((String) h.get("indent")); if (indent != null && indent.matches("[0-9]+")) { list.setSymbolIndent(Integer.valueOf(indent)); } stack.push(list); return; } if (tag.equals("li")) { if (pendingLI) endElement("li"); skipText = false; pendingLI = true; cprops.addToChain(tag, h); stack.push(FactoryProperties.createListItem(cprops)); return; } if (tag.equals("div") || tag.equals("body")) { cprops.addToChain(tag, h); return; } if (tag.equals("pre")) { if (!h.containsKey("face")) { h.put("face", "Courier"); } cprops.addToChain(tag, h); isPRE = true; return; } if (tag.equals("p")) { cprops.addToChain(tag, h); currentParagraph = FactoryProperties.createParagraph(h); return; } if (tag.equals("tr")) { if (pendingTR) endElement("tr"); skipText = true; pendingTR = true; cprops.addToChain("tr", h); return; } if (tag.equals("td") || tag.equals("th")) { if (pendingTD) endElement(tag); skipText = false; pendingTD = true; cprops.addToChain("td", h); stack.push(new IncCell(tag, cprops)); return; } if (tag.equals("table")) { cprops.addToChain("table", h); IncTable table = new IncTable(h); stack.push(table); tableState.push(new boolean[] { pendingTR, pendingTD }); pendingTR = pendingTD = false; skipText = true; return; } } catch (Exception e) { throw new ExceptionConverter(e); } }
From source file:optika.sql.java
public void eksportoNePdf(String id) { Document document = new Document() { };/*from w w w.ja v a 2 s. c o m*/ try { PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("receta.pdf")); document.open(); document.setPageSize(PageSize.A3); Image img = Image.getInstance("receta.jpg"); img.setAbsolutePosition(450f, 10f); img.scaleToFit(600, 849); img.setAlignment(Image.LEFT | Image.ALIGN_BOTTOM | Image.ALIGN_BASELINE); img.setAbsolutePosition(0, 0); document.add(img); String[][] receta = merrReceten("select * from recetat where id=" + parseInt(id) + ";"); String[][] tabela = merrReceten("select * from tabela where recetat_id=" + parseInt(id) + ";"); int[] white = new int[tabela.length]; for (int i = 0; i < tabela.length; i++) { white[i] = 0; int bosh = 0; for (int j = 3; j < tabela[i].length; j++) { if (tabela[i][j] == tabela[i][6]) { continue; } if (!tabela[i][j].isEmpty()) { bosh = 1; } } if (bosh == 0) { white[i] = 1; } } Paragraph data = new Paragraph("Data: " + receta[0][7]); data.setSpacingBefore(38); data.setSpacingAfter(40); PdfPTable table = new PdfPTable(7); if (white[0] == 0) { table.addCell(getCellPadding("" + tabela[0][3], 1)); } else { table.addCell(getCellWhite("_", 1, 30)); } table.addCell(getCellPadding("" + tabela[0][4], 1)); table.addCell(getCellPadding("" + tabela[0][5], 1)); table.addCell(getCellPadding("", 1)); table.addCell(getCellPadding("" + tabela[0][7], 1)); table.addCell(getCellPadding("" + tabela[0][8], 1)); table.addCell(getCellPadding("" + tabela[0][9], 1)); table.setWidthPercentage(105); table.setHorizontalAlignment(-100); if (white[1] == 0) { table.addCell(getCellPadding("" + tabela[1][3], 1)); } else { table.addCell(getCellWhite("_", 1, 36)); } table.addCell(getCellPadding("" + tabela[1][4], 1)); table.addCell(getCellPadding("" + tabela[1][5], 1)); table.addCell(getCellPadding("", 1)); table.addCell(getCellPadding("" + tabela[1][7], 1)); table.addCell(getCellPadding("" + tabela[1][8], 1)); table.addCell(getCellPadding("" + tabela[1][9], 1)); table.setWidthPercentage(105); table.setHorizontalAlignment(-100); if (white[2] == 0) { if (white[1] == 0) { table.addCell(getCell("" + tabela[2][3], 1, 30)); } else { table.addCell(getCellWhite("_", 1, 23)); } } else { table.addCell(getCellWhite("_", 1, 28)); } table.addCell(getCell("" + tabela[2][4], 1, 0)); table.addCell(getCell("" + tabela[2][5], 1, 0)); table.addCell(getCell("", 1, 0)); table.addCell(getCell("" + tabela[2][7], 1, 0)); table.addCell(getCell("" + tabela[2][8], 1, 0)); table.addCell(getCell("" + tabela[2][9], 1, 0)); table.setWidthPercentage(105); table.setSpacingBefore(27); table.setHorizontalAlignment(-100); String[][] distanca = merrReceten("select * from distanca where recetat_id=" + parseInt(id) + ";"); PdfPTable largAfer = new PdfPTable(3); if (distanca[0][3].isEmpty()) { PdfPCell larg = getCellWhite("_", 2, 15); largAfer.addCell(larg); } else { PdfPCell larg = new PdfPCell(new Phrase("" + distanca[0][3])); larg.setPadding(0); larg.setHorizontalAlignment(2); larg.setBorder(PdfPCell.NO_BORDER); larg.setPaddingBottom(20); largAfer.addCell(larg); } largAfer.addCell(getCell("", PdfPCell.ALIGN_RIGHT, 25)); if (distanca[0][8].isEmpty()) { largAfer.addCell(getCellWhite("_", PdfPCell.ALIGN_RIGHT, 15)); } else { largAfer.addCell(getCell("" + distanca[0][8], PdfPCell.ALIGN_RIGHT, 25)); } largAfer.setWidthPercentage(75); largAfer.setHorizontalAlignment(350); PdfPTable od_os = new PdfPTable(5); od_os.addCell(getCell("OD= " + distanca[0][4], 0, 195)); od_os.addCell(getCell("OS= " + distanca[0][5], 2, 195)); od_os.addCell(getCell("", 0, 0)); od_os.addCell(getCell("OD= " + distanca[0][9], 0, 0)); od_os.addCell(getCell("OS= " + distanca[0][10], 1, 0)); od_os.setWidthPercentage(90); od_os.setHorizontalAlignment(150); PdfPTable visusi = new PdfPTable(2); if (distanca[0][6].isEmpty()) { PdfPCell od_pa = getCellWhite("_", 2, 17); od_pa.setPaddingRight(45); visusi.addCell(od_pa); } else { PdfPCell od_pa = getCell(distanca[0][6], 2, 17); od_pa.setPaddingRight(45); visusi.addCell(od_pa); } if (distanca[0][11].isEmpty()) { visusi.addCell(getCellWhite("_", 2, 17)); } else { visusi.addCell(getCell(distanca[0][11], 2, 17)); } if (distanca[0][7].isEmpty()) { PdfPCell os_pa = getCellWhite("_", 2, 17); os_pa.setPaddingRight(45); visusi.addCell(os_pa); } else { PdfPCell os_pa = getCell(distanca[0][7], 2, 17); os_pa.setPaddingRight(45); visusi.addCell(os_pa); } if (distanca[0][12].isEmpty()) { visusi.addCell(getCellWhite("_", 2, 17)); } else { visusi.addCell(getCell(distanca[0][12], 2, 0)); } visusi.setWidthPercentage(100); visusi.setHorizontalAlignment(50); String[][] admin = merrReceten("select * from admin where id=1;"); PdfPTable klienti = new PdfPTable(3); klienti.addCell(getCell("", 0, 0)); klienti.addCell(getCell("", 0, 0)); klienti.addCell(getCell("Emri: " + receta[0][2], 0, 0)); klienti.addCell(getCell("Celular: " + admin[0][4], 0, 0)); klienti.addCell(getCell("", 0, 0)); PdfPCell celReceta = getCell("Celular: " + receta[0][4], 0, 0); celReceta.setPaddingTop(5); klienti.addCell(celReceta); klienti.addCell(getCell("Email: " + admin[0][5], 0, 0)); klienti.addCell(getCell("", 0, 0)); PdfPCell emailReceta = getCell("Email: " + receta[0][5], 0, 0); emailReceta.setPaddingBottom(5); emailReceta.setPaddingTop(5); klienti.addCell(emailReceta); klienti.addCell(getCell("Adresa: " + admin[0][6], 0, 0)); klienti.addCell(getCell("", 0, 0)); klienti.addCell(getCell("Adresa: " + receta[0][6], 0, 0)); klienti.setSpacingBefore(50); PdfPTable kreu = new PdfPTable(1); kreu.addCell(getCell(" ", 0, 0)); document.add(kreu); document.add(klienti); document.add(data); document.add(table); document.add(largAfer); document.add(od_os); document.add(visusi); } catch (DocumentException de) { System.err.println(de.getMessage()); } catch (IOException ioe) { System.err.println(ioe.getMessage()); } document.close(); }
From source file:org.cgiar.ccafs.ap.summaries.projects.pdf.ProjectSummaryPDF.java
License:Open Source License
private void addProjectLocations() { Paragraph title = new Paragraph("3. " + this.getText("summaries.projectLocation.title"), HEADING3_FONT); Paragraph cell;// w w w . j a v a2 s .c om StringBuffer projectLocations = new StringBuffer(); List<Location> locationList = (project.getLocations()); PdfPTable table; try { document.newPage(); document.add(title); if (project.isGlobal()) { Image global = Image.getInstance(config.getBaseUrl() + "/images/summaries/global-map.png"); global.scalePercent(60f); global.setAlignment(Element.ALIGN_CENTER); document.add(global); } else if (locationList.isEmpty()) { cell = new Paragraph(); cell.setFont(BODY_TEXT_FONT); cell.add(this.getText("summaries.project.empty")); document.add(cell); } else { table = new PdfPTable(4); // Set table widths table.setLockedWidth(true); table.setTotalWidth(480); table.setWidths(new int[] { 4, 4, 4, 5 }); table.setHeaderRows(1); // Headers cell = new Paragraph(this.getText("summaries.projectLocation.table.level"), TABLE_HEADER_FONT); this.addTableHeaderCell(table, cell); cell = new Paragraph(this.getText("summaries.projectLocation.table.latitude"), TABLE_HEADER_FONT); this.addTableHeaderCell(table, cell); cell = new Paragraph(this.getText("summaries.projectLocation.table.longitude"), TABLE_HEADER_FONT); this.addTableHeaderCell(table, cell); cell = new Paragraph(this.getText("summaries.projectLocation.table.name"), TABLE_HEADER_FONT); this.addTableHeaderCell(table, cell); double answer = 0; OtherLocation otherLocation; for (Location location : locationList) { answer = 0; projectLocations = new StringBuffer(); // Level if (location.isCountry()) { projectLocations.append("Country"); } else if (location.isRegion()) { projectLocations.append("Region"); } else if (location.isClimateSmartVillage()) { projectLocations.append("CSV"); } else if (location.isOtherLocation()) { otherLocation = (OtherLocation) location; projectLocations.append(otherLocation.getType().getName()); } cell = new Paragraph(); cell.setFont(TABLE_BODY_FONT); cell.add(projectLocations.toString()); this.addTableBodyCell(table, cell, Element.ALIGN_CENTER, 1); // Latitude projectLocations = new StringBuffer(); if (location.isOtherLocation()) { otherLocation = (OtherLocation) location; answer = otherLocation.getGeoPosition().getLatitude(); cell = new Paragraph(); cell.setFont(TABLE_BODY_FONT); if (answer != 0) { cell.add(String.valueOf(answer)); } else { cell.add("Not applicable"); } this.addTableBodyCell(table, cell, Element.ALIGN_CENTER, 1); // Longitude answer = otherLocation.getGeoPosition().getLatitude(); cell = new Paragraph(); cell.setFont(TABLE_BODY_FONT); if (answer != 0) { cell.add(String.valueOf(answer)); } else { cell.add("Not applicable"); } this.addTableBodyCell(table, cell, Element.ALIGN_CENTER, 1); } else { // Latitude cell = new Paragraph(); cell.setFont(TABLE_BODY_FONT); cell.add("Not applicable"); this.addTableBodyCell(table, cell, Element.ALIGN_CENTER, 1); cell = new Paragraph(); cell.setFont(TABLE_BODY_FONT); // Longitude cell.add("Not applicable"); this.addTableBodyCell(table, cell, Element.ALIGN_CENTER, 1); } // Name cell = new Paragraph(); cell.setFont(TABLE_BODY_FONT); projectLocations = new StringBuffer(); projectLocations.append(location.getName()); cell.add(projectLocations.toString()); this.addTableBodyCell(table, cell, Element.ALIGN_CENTER, 1); } title = new Paragraph(); title.add(Chunk.NEWLINE); title.add(Chunk.NEWLINE); document.add(title); document.add(table); if (!project.isReporting()) { // Lesson regarding locations Paragraph locationsBlock = new Paragraph(); locationsBlock.setAlignment(Element.ALIGN_JUSTIFIED); locationsBlock.add(Chunk.NEWLINE); locationsBlock.add(Chunk.NEWLINE); locationsBlock.setFont(BODY_TEXT_BOLD_FONT); locationsBlock.add(this.getText("summaries.project.location.lessonRegarding")); locationsBlock.setFont(BODY_TEXT_FONT); if (project.getComponentLesson("locations") != null) { locationsBlock .add(this.messageReturn(project.getComponentLesson("locations").getLessons())); } else { locationsBlock.add(this.messageReturn(null)); } document.add(locationsBlock); } } } catch (DocumentException e) { LOG.error("There was an error trying to add the project locations to the project summary pdf", e); } catch (MalformedURLException e) { LOG.error("There was an error trying to add the project focuses to the project summary pdf", e); e.printStackTrace(); } catch (IOException e) { LOG.error("There was an error trying to add the project focuses to the project summary pdf", e); e.printStackTrace(); } }
From source file:org.cgiar.ccafs.ap.summaries.projects.pdf.ProjectSummaryPDF.java
License:Open Source License
/** * Entering the project outputs in the summary *///from w ww. j a va 2 s .c o m private void addProjectOutputs(String number) { // ********************************************************************************** // *************************** Overview By Mog ************************************* // ********************************************************************************** try { Paragraph overview_title = new Paragraph(); overview_title.setFont(HEADING2_FONT); overview_title.add(number + ". " + this.getText("summaries.project.projectOutput")); overview_title.add(Chunk.NEWLINE); overview_title.add(Chunk.NEWLINE); document.newPage(); document.add(overview_title); overview_title = new Paragraph(); overview_title.setFont(HEADING3_FONT); overview_title.add(number + ".1 " + this.getText("summaries.project.overviewbymogs")); document.add(overview_title); } catch (DocumentException e) { LOG.error("There was an error trying to add the project title to the project summary pdf", e); } int[] years = { midOutcomeYear, project.isReporting() ? this.currentReportingYear - 1 : this.currentReportingYear - 1, project.isReporting() ? this.currentReportingYear : this.currentPlanningYear, project.isReporting() ? this.currentReportingYear + 1 : this.currentReportingYear + 1 }; Paragraph paragraph = new Paragraph(); List<IPElement> mogs = project.getOutputs(); try { if (mogs.isEmpty()) { paragraph.add(this.getText("summaries.project.empty")); document.add(paragraph); } else { // year PdfPTable table; for (int a = 0; a < years.length; a++) { paragraph = new Paragraph(); paragraph.setFont(TABLE_HEADER_FONT); paragraph.add(this.getText("summaries.project.overviewbymogs.text") + "- " + years[a]); table = new PdfPTable(1); table.setLockedWidth(true); table.setTotalWidth(480); this.addTableHeaderCell(table, paragraph); // Mog for (int b = 0; b < mogs.size(); b++) { this.addOverview(table, mogs.get(b), years[a]); } paragraph = new Paragraph(); paragraph.add(Chunk.NEWLINE); document.add(paragraph); document.add(table); } // Leason regardins paragraph = new Paragraph(); paragraph.add(Chunk.NEWLINE); paragraph.setAlignment(Element.ALIGN_JUSTIFIED); paragraph.setFont(BODY_TEXT_BOLD_FONT); if (!project.isReporting()) { paragraph.add(this.getText("summaries.project.output.lessonRegarding")); } else { paragraph.add(this.getText("summaries.project.overviewbymogs.reporting.lesson")); } paragraph.setFont(BODY_TEXT_FONT); if (project.getComponentLesson("outputs") != null) { paragraph.add(this.messageReturn(project.getComponentLesson("outputs").getLessons())); } else { paragraph.add(this.messageReturn(null)); } paragraph.add(Chunk.NEWLINE); paragraph.add(Chunk.NEWLINE); document.add(paragraph); } } catch (DocumentException e) { LOG.error("There was an error trying to add the project title to the project summary pdf", e); } // ********************************************************************************** // *************************** Deliverables.**************************************** // ********************************************************************************** int counter = 1; try { document.newPage(); paragraph = new Paragraph(); paragraph.setFont(HEADING3_FONT); paragraph.add(number + ".2 " + this.getText("summaries.project.deliverable.title")); document.add(paragraph); paragraph = new Paragraph(); List<Deliverable> listDeliverables = project.getDeliverables(); if (listDeliverables.isEmpty()) { paragraph.add(this.getText("summaries.project.empty")); document.add(paragraph); } else { paragraph.add(Chunk.NEWLINE); document.add(paragraph); for (Deliverable deliverable : listDeliverables) { if (!project.isReporting()) { if (deliverable.getYear() == config.getPlanningCurrentYear()) { this.addDelivable(deliverable, counter); counter++; } } } } // ********************************************************************************** // *************************** Next users.**************************************** // ********************************************************************************** if (project.isReporting()) { counter = 1; document.newPage(); paragraph = new Paragraph(); paragraph.setFont(HEADING3_FONT); paragraph.add(number + ".3 " + this.getText("summaries.project.reporting.nextuser.title")); document.add(paragraph); PdfPTable table; if (project.getNextUsers().isEmpty()) { paragraph = new Paragraph(); paragraph.add(this.messageReturn(null)); paragraph.add(Chunk.NEWLINE); document.add(paragraph); } else { paragraph = new Paragraph(); paragraph.add(Chunk.NEWLINE); document.add(paragraph); for (ProjectNextUser projectNextUser : project.getNextUsers()) { paragraph = new Paragraph(); paragraph.setFont(TABLE_HEADER_FONT); paragraph.setAlignment(Element.ALIGN_LEFT); table = new PdfPTable(1); table.setLockedWidth(true); table.setTotalWidth(480); paragraph.add(this.getText("summaries.project.reporting.nextuser", new String[] { String.valueOf(counter) })); this.addTableHeaderCell(table, paragraph); // Next users key paragraph = new Paragraph(); paragraph.setFont(TABLE_BODY_BOLD_FONT); paragraph.add(this.getText("summaries.project.reporting.nextuser.currentPeriod")); paragraph.setFont(TABLE_BODY_FONT); if (projectNextUser != null) { paragraph.add(this.messageReturn(projectNextUser.getKeyNextUser())); } else { paragraph.add(this.messageReturn(null)); } this.addTableBodyCell(table, paragraph, Element.ALIGN_LEFT, 1); // Strategies paragraph = new Paragraph(); paragraph.setFont(TABLE_BODY_BOLD_FONT); paragraph.add(this.getText("summaries.project.reporting.nextuser.strategies")); paragraph.setFont(TABLE_BODY_FONT); if (projectNextUser != null) { paragraph.add(this.messageReturn(projectNextUser.getStrategies())); } else { paragraph.add(this.messageReturn(null)); } this.addTableBodyCell(table, paragraph, Element.ALIGN_LEFT, 1); // reported paragraph = new Paragraph(); paragraph.setFont(TABLE_BODY_BOLD_FONT); paragraph.add(this.getText("summaries.project.reporting.nextuser.reported")); paragraph.setFont(TABLE_BODY_FONT); if (projectNextUser != null) { paragraph.add(this.messageReturn(projectNextUser.getReportedDeliverables())); } else { paragraph.add(this.messageReturn(null)); } this.addTableBodyCell(table, paragraph, Element.ALIGN_LEFT, 1); // lessons paragraph = new Paragraph(); paragraph.setFont(TABLE_BODY_BOLD_FONT); paragraph.add(this.getText("summaries.project.reporting.nextuser.lessons")); paragraph.setFont(TABLE_BODY_FONT); if (projectNextUser != null) { paragraph.add(this.messageReturn(projectNextUser.getLessonsImplications())); } else { paragraph.add(this.messageReturn(null)); } this.addTableBodyCell(table, paragraph, Element.ALIGN_LEFT, 1); counter++; document.add(table); paragraph = new Paragraph(); paragraph.add(Chunk.NEWLINE); document.add(paragraph); } } // ********************************************************************************** // *************************** Project HighLights**************************************** // ********************************************************************************** counter = 1; document.newPage(); paragraph = new Paragraph(); paragraph.setFont(HEADING3_FONT); paragraph.add(number + ".4 " + this.getText("summaries.project.reporting.highlight.principal")); document.add(paragraph); paragraph = new Paragraph(); paragraph.add(Chunk.NEWLINE); document.add(paragraph); for (ProjectHighligths projectHighLigth : project.getHighlights()) { table = new PdfPTable(2); table.setLockedWidth(true); table.setTotalWidth(480); paragraph = new Paragraph(); paragraph.setFont(TABLE_HEADER_FONT); paragraph.add(this.getText("summaries.project.reporting.highlight", new String[] { String.valueOf(counter) })); this.addTableHeaderCellColspan(table, paragraph, 2); // title paragraph = new Paragraph(); paragraph.setFont(TABLE_BODY_BOLD_FONT); paragraph.add(this.getText("summaries.project.reporting.highlight.title")); paragraph.setFont(TABLE_BODY_FONT); if (projectHighLigth != null) { paragraph.add(this.messageReturn(projectHighLigth.getTitle())); } else { paragraph.add(this.messageReturn(null)); } this.addTableColSpanCell(table, paragraph, Element.ALIGN_LEFT, 1, 2); // author paragraph = new Paragraph(); paragraph.setFont(TABLE_BODY_BOLD_FONT); paragraph.add(this.getText("summaries.project.reporting.highlight.author")); paragraph.setFont(TABLE_BODY_FONT); if (projectHighLigth != null) { paragraph.add(this.messageReturn(projectHighLigth.getAuthor())); } else { paragraph.add(this.messageReturn(null)); } this.addTableBodyCell(table, paragraph, Element.ALIGN_LEFT, 1); // subject paragraph = new Paragraph(); paragraph.setFont(TABLE_BODY_BOLD_FONT); paragraph.add(this.getText("summaries.project.reporting.highlight.subject")); paragraph.setFont(TABLE_BODY_FONT); if (projectHighLigth != null) { paragraph.add(this.messageReturn(projectHighLigth.getSubject())); } else { paragraph.add(this.messageReturn(null)); } this.addTableBodyCell(table, paragraph, Element.ALIGN_LEFT, 1); // publisher paragraph = new Paragraph(); paragraph.setFont(TABLE_BODY_BOLD_FONT); paragraph.add(this.getText("summaries.project.reporting.highlight.publisher")); paragraph.setFont(TABLE_BODY_FONT); if (projectHighLigth != null) { paragraph.add(this.messageReturn(projectHighLigth.getPublisher())); } else { paragraph.add(this.messageReturn(null)); } this.addTableBodyCell(table, paragraph, Element.ALIGN_LEFT, 1); // year paragraph = new Paragraph(); paragraph.setFont(TABLE_BODY_BOLD_FONT); paragraph.add(this.getText("summaries.project.reporting.highlight.year")); paragraph.setFont(TABLE_BODY_FONT); if (projectHighLigth != null) { paragraph.add(this.messageReturn(String.valueOf(projectHighLigth.getYear()))); } else { paragraph.add(this.messageReturn(null)); } this.addTableBodyCell(table, paragraph, Element.ALIGN_LEFT, 1); // project highlight types paragraph = new Paragraph(); paragraph.setFont(TABLE_BODY_BOLD_FONT); paragraph.add(this.getText("summaries.project.reporting.highlight.types")); paragraph.setFont(TABLE_BODY_FONT); if (projectHighLigth != null) { for (ProjectHighligthsTypes projectHighLigthTypes : projectHighLigth .getProjectHighligthsTypeses()) { paragraph.add(this.messageReturn("\n" + ProjectHighlightsType .getEnum(String.valueOf(projectHighLigthTypes.getIdType())).getDescription())); } } else { paragraph.add(this.messageReturn(null)); } this.addTableBodyCell(table, paragraph, Element.ALIGN_LEFT, 1); // project images paragraph = new Paragraph(); paragraph.setFont(TABLE_BODY_BOLD_FONT); paragraph.add("Image"); if (projectHighLigth != null) { Image global; try { if (projectHighLigth.getPhoto() != null) { String urlImage = config.getDownloadURL() + "/" + this.getHighlightsImagesUrlPath() + projectHighLigth.getPhoto(); urlImage = urlImage.replace(" ", "%20"); global = Image.getInstance(urlImage); } else { global = null; } if (global != null) { float documentWidth = document.getPageSize().getWidth() - document.leftMargin() - document.rightMargin(); float documentHeight = document.getPageSize().getHeight() - document.topMargin() - document.bottomMargin(); global.scaleToFit((float) (documentWidth * 0.4), global.getHeight()); global.setAlignment(Element.ALIGN_CENTER); this.addTableBodyCell(table, global, Element.ALIGN_LEFT, 1); } } catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } else { paragraph.add(this.messageReturn(null)); } // project start date paragraph = new Paragraph(); paragraph.setFont(TABLE_BODY_BOLD_FONT); paragraph.add(this.getText("summaries.project.reporting.highlight.startDate")); paragraph.setFont(TABLE_BODY_FONT); if (projectHighLigth != null) { paragraph.add(this.messageReturn(String.valueOf(projectHighLigth.getStartDate()))); } else { paragraph.add(this.messageReturn(null)); } this.addTableBodyCell(table, paragraph, Element.ALIGN_LEFT, 1); // project end date paragraph = new Paragraph(); paragraph.setFont(TABLE_BODY_BOLD_FONT); paragraph.add(this.getText("summaries.project.reporting.highlight.endDate")); paragraph.setFont(TABLE_BODY_FONT); if (projectHighLigth != null) { paragraph.add(this.messageReturn(String.valueOf(projectHighLigth.getEndDate()))); } else { paragraph.add(this.messageReturn(null)); } this.addTableBodyCell(table, paragraph, Element.ALIGN_LEFT, 1); // Its Global paragraph = new Paragraph(); paragraph.setFont(TABLE_BODY_BOLD_FONT); paragraph.add(this.getText("summaries.project.reporting.highlight.itsglobal")); paragraph.setFont(TABLE_BODY_FONT); if (projectHighLigth != null) { if (projectHighLigth.isIsGlobal()) { paragraph.add("Yes"); } else { paragraph.add("No"); } ; } else { paragraph.add(this.messageReturn(null)); } this.addTableColSpanCell(table, paragraph, Element.ALIGN_LEFT, 1, 2); // Country paragraph = new Paragraph(); paragraph.setFont(TABLE_BODY_BOLD_FONT); paragraph.add(this.getText("summaries.project.reporting.highlight.country")); paragraph.setFont(TABLE_BODY_FONT); if (projectHighLigth != null && projectHighLigth.getProjectHighligthsCountries() != null) { for (ProjectHighligthsCountry country : projectHighLigth.getProjectHighligthsCountries()) { paragraph.add(locationManager.getCountry(country.getIdCountry()).getName() + "\n"); } } else { paragraph.add(this.messageReturn(null)); } this.addTableBodyCell(table, paragraph, Element.ALIGN_LEFT, 1); paragraph = new Paragraph(); paragraph.setFont(TABLE_BODY_BOLD_FONT); paragraph.add(this.getText("summaries.project.reporting.highlight.keywords")); paragraph.setFont(TABLE_BODY_FONT); if (projectHighLigth != null) { paragraph.add(this.messageReturn(projectHighLigth.getKeywords())); } else { paragraph.add(this.messageReturn(null)); } this.addTableColSpanCell(table, paragraph, Element.ALIGN_LEFT, 1, 2); // description paragraph = new Paragraph(); paragraph.setFont(TABLE_BODY_BOLD_FONT); paragraph.add(this.getText("summaries.project.reporting.highlight.description")); paragraph.setFont(TABLE_BODY_FONT); if (projectHighLigth != null) { paragraph.add(this.messageReturn(projectHighLigth.getDescription())); } else { paragraph.add(this.messageReturn(null)); } this.addTableColSpanCell(table, paragraph, Element.ALIGN_LEFT, 1, 2); // Introduction / Objectives paragraph = new Paragraph(); paragraph.setFont(TABLE_BODY_BOLD_FONT); paragraph.add(this.getText("summaries.project.reporting.highlight.introduction")); paragraph.setFont(TABLE_BODY_FONT); if (projectHighLigth != null) { paragraph.add(this.messageReturn(projectHighLigth.getObjectives())); } else { paragraph.add(this.messageReturn(null)); } this.addTableColSpanCell(table, paragraph, Element.ALIGN_LEFT, 1, 2); // Results paragraph = new Paragraph(); paragraph.setFont(TABLE_BODY_BOLD_FONT); paragraph.add(this.getText("summaries.project.reporting.highlight.results")); paragraph.setFont(TABLE_BODY_FONT); if (projectHighLigth != null) { paragraph.add(this.messageReturn(projectHighLigth.getResults())); } else { paragraph.add(this.messageReturn(null)); } this.addTableColSpanCell(table, paragraph, Element.ALIGN_LEFT, 1, 2); // Partners paragraph = new Paragraph(); paragraph.setFont(TABLE_BODY_BOLD_FONT); paragraph.add(this.getText("summaries.project.reporting.highlight.partners")); paragraph.setFont(TABLE_BODY_FONT); if (projectHighLigth != null) { paragraph.add(this.messageReturn(projectHighLigth.getPartners())); } else { paragraph.add(this.messageReturn(null)); } this.addTableColSpanCell(table, paragraph, Element.ALIGN_LEFT, 1, 2); // Links paragraph = new Paragraph(); paragraph.setFont(TABLE_BODY_BOLD_FONT); paragraph.add(this.getText("summaries.project.reporting.highlight.links")); paragraph.setFont(TABLE_BODY_FONT); paragraph.add(this.messageReturn(projectHighLigth.getLinks())); this.addTableColSpanCell(table, paragraph, Element.ALIGN_LEFT, 1, 2); document.add(table); document.newPage(); } } } catch (DocumentException e) { LOG.error("There was an error trying to add the project title to the project summary pdf", e); } }