List of usage examples for com.lowagie.text Paragraph setSpacingAfter
public void setSpacingAfter(float spacing)
From source file:org.sakaiproject.evaluation.tool.reporting.EvalPDFReportBuilder.java
License:Educational Community License
public void addCommentList(String header, List<String> textItems, String none, String textNumberOfComments) { ArrayList<Element> myElements = new ArrayList<>(); com.lowagie.text.List list = new com.lowagie.text.List(com.lowagie.text.List.UNORDERED); Paragraph emptyPara = new Paragraph(" ", paragraphFont); myElements.add(emptyPara);//from w w w . j ava 2 s.c o m Paragraph para = new Paragraph(header, paragraphFontBold); para.setSpacingAfter(SPACING_AFTER_COMMENT_TITLE); myElements.add(para); if (textItems == null || textItems.isEmpty()) { Paragraph p = new Paragraph(none, paragraphFont); myElements.add(p); } else { list.setListSymbol("\u2022 "); list.setIndentationLeft(20f); for (String text : textItems) { if (text != null && text.length() > 0) { com.lowagie.text.ListItem item = new com.lowagie.text.ListItem(text, this.paragraphFont); item.setKeepTogether(false); item.setSpacingAfter(SPACING_BETWEEN_LIST_ITEMS); list.add(item); } } myElements.add(list); LOG.debug("Current comment list has " + textItems.size() + " comments."); myElements.add(new Paragraph(textNumberOfComments + " : " + textItems.size(), paragraphFont)); } //With more than 30 answers, we do not try to calculate the space. if (list.size() <= 30) { this.addElementArrayWithJump(myElements); } else { this.addBigElementArray(myElements); } }
From source file:org.sakaiproject.evaluation.tool.reporting.EvalPDFReportBuilder.java
License:Educational Community License
public void addTextItemsList(String header, List<String> textItems, boolean comment, String textNumberOfAnswers) { ArrayList<Element> myElements = new ArrayList<>(); com.lowagie.text.List list = new com.lowagie.text.List(com.lowagie.text.List.UNORDERED); list.setListSymbol("\u2022 "); list.setIndentationLeft(20f);// w w w. jav a2 s. co m int numItem = 0; for (String text : textItems) { numItem++; if (text != null && text.length() > 0) { com.lowagie.text.ListItem item = new com.lowagie.text.ListItem(text, this.paragraphFont); item.setKeepTogether(false); item.setSpacingBefore(SPACING_BETWEEN_LIST_ITEMS); if (numItem < textItems.size()) item.setSpacingAfter(1f); else item.setSpacingAfter(SPACING_AFTER_LAST_LIST_ITEM); list.add(item); } } if (!comment) { Paragraph emptyPara = new Paragraph(" "); myElements.add(emptyPara); Paragraph para = new Paragraph(header, questionTextFont); para.setSpacingAfter(SPACING_AFTER_COMMENT_TITLE); myElements.add(para); } else { Paragraph emptyPara = new Paragraph(" "); myElements.add(emptyPara); Paragraph para = new Paragraph(header, paragraphFont); para.setSpacingAfter(SPACING_AFTER_LIST_TITLE); myElements.add(para); } myElements.add(list); myElements.add(new Paragraph(textNumberOfAnswers + " : " + textItems.size(), paragraphFont)); //With more than 30 answers, we do not try to calculate the space. if (list.size() <= 30) { this.addElementArrayWithJump(myElements); } else { this.addBigElementArray(myElements); } }
From source file:org.sakaiproject.evaluation.tool.reporting.EvalPDFReportBuilder.java
License:Educational Community License
/** * @param question//from w w w . j a v a2 s . c o m * the question text * @param choices * the text for the choices * @param values * the count of answers for each choice (same order as choices) * @param responseCount * the number of responses to the question * @param showPercentages * if true then show the percentages * @param answersAndMean * the text which will be displayed above the chart (normally the answers count and * mean) * @param lastElementIsHeader * If the last element was a header, the extra spacing paragraph is not needed. */ public void addLikertResponse(String question, String[] choices, int[] values, int responseCount, boolean showPercentages, String answersAndMean, boolean lastElementIsHeader) { ArrayList<Element> myElements = new ArrayList<>(); try { if (!lastElementIsHeader) { Paragraph emptyPara = new Paragraph(" "); this.addElementWithJump(emptyPara, false); } Paragraph myPara = new Paragraph(question, questionTextFont); myPara.setSpacingAfter(SPACING_AFTER_HEADER); myElements.add(myPara); EvalLikertChartBuilder chartBuilder = new EvalLikertChartBuilder(); chartBuilder.setValues(values); chartBuilder.setResponses(choices); chartBuilder.setShowPercentages(showPercentages); chartBuilder.setResponseCount(responseCount); JFreeChart chart = chartBuilder.makeLikertChart(); /* The height is going to be based off the number of choices */ int height = 15 * choices.length; PdfContentByte cb = pdfWriter.getDirectContent(); PdfTemplate tp = cb.createTemplate(200, height); Graphics2D g2d = tp.createGraphics(200, height, new DefaultFontMapper()); Rectangle2D r2d = new Rectangle2D.Double(0, 0, 200, height); chart.draw(g2d, r2d); g2d.dispose(); Image image = Image.getInstance(tp); // put image in the document myElements.add(image); if (answersAndMean != null) { Paragraph header = new Paragraph(answersAndMean, paragraphFont); header.setSpacingAfter(SPACING_BETWEEN_LIST_ITEMS); myElements.add(header); } this.addElementArrayWithJump(myElements); } catch (BadElementException e) { // TODO Auto-generated catch block LOG.warn(e); } }
From source file:org.sakaiproject.evaluation.tool.reporting.EvalPDFReportBuilder.java
License:Educational Community License
public void addRegularText(String text) { Paragraph para = new Paragraph(text, paragraphFont); para.setSpacingAfter(SPACING_AFTER_HEADER); //this.addElementWithJump(para, false); this.addLittleElementWithJump(para); }
From source file:org.sigmah.server.report.renderer.itext.ThemeHelper.java
License:Open Source License
public static Paragraph reportTitle(String title) { Paragraph para = new Paragraph(title); para.setFont(new Font(Font.TIMES_ROMAN, 26, Font.NORMAL, new Color(23, 54, 93))); para.setSpacingAfter(15); return para;// w w w.ja v a2 s.co m }
From source file:org.tellervo.desktop.print.CompleteBoxLabel.java
License:Open Source License
public void generateBoxLabel(OutputStream output) { try {/*from ww w.j a va 2s .com*/ PdfWriter writer = PdfWriter.getInstance(document, output); document.setPageSize(PageSize.LETTER); document.open(); cb = writer.getDirectContent(); // Set basic metadata document.addAuthor("Peter Brewer"); document.addSubject("Box Label"); for (WSIBox b : this.boxlist) { // Title Left ColumnText ct = new ColumnText(cb); ct.setSimpleColumn(document.left(), document.top(15) - 210, 368, document.top(15), 20, Element.ALIGN_LEFT); ct.addText(getTitlePDF(b)); ct.go(); // Barcode ColumnText ct2 = new ColumnText(cb); ct2.setSimpleColumn(370, document.top(15) - 100, document.right(0), document.top(0), 20, Element.ALIGN_RIGHT); ct2.addElement(getBarCode(b)); ct2.go(); // Timestamp ColumnText ct3 = new ColumnText(cb); ct3.setSimpleColumn(document.left(), document.top(15) - 223, 350, document.top(15) - 60, 20, Element.ALIGN_LEFT); ct3.setLeading(0, 1.2f); ct3.addText(getTimestampPDF(b)); ct3.go(); // Pad text document.add(new Paragraph(" ")); Paragraph p2 = new Paragraph(); p2.setSpacingBefore(70); p2.setSpacingAfter(10); p2.add(new Chunk(" ", bodyFontLarge)); document.add(new Paragraph(p2)); // Ring samples table addTable(b); document.add(getParagraphSpace()); document.add(getComments(b)); document.newPage(); } } catch (DocumentException de) { System.err.println(de.getMessage()); } // Close the document document.close(); }
From source file:org.tellervo.desktop.print.ProSheet.java
License:Open Source License
private Paragraph getObjectDescription() { Paragraph p = new Paragraph(); p.setLeading(0, 1.2f);/*ww w . java 2 s . co m*/ p.setAlignment(Element.ALIGN_JUSTIFIED); p.setSpacingAfter(10); p.setSpacingBefore(50); if (o.getDescription() != null) { p.add(new Chunk(o.getDescription(), bodyFont)); } else { p.add(new Chunk("No description recorded", bodyFont)); } return p; }
From source file:org.tellervo.desktop.print.ProSheet.java
License:Open Source License
private Paragraph getObjectComments() { Paragraph p = new Paragraph(); p.setLeading(0, 1.2f);//w w w . j a va 2 s . c om p.setAlignment(Element.ALIGN_JUSTIFIED); p.setSpacingAfter(10); if (o.getComments() != null) { p.add(new Chunk("Notes: ", commentFont)); p.add(new Chunk(o.getComments(), commentFont)); } return p; }
From source file:org.tellervo.desktop.print.SeriesReport.java
License:Open Source License
private void generateSeriesReport(OutputStream output) { displayUnits = NormalTridasUnit// w w w .j av a 2 s . c o m .valueOf(App.prefs.getPref(PrefKey.DISPLAY_UNITS, NormalTridasUnit.MICROMETRES.name().toString())); try { PdfWriter writer = PdfWriter.getInstance(document, output); document.setPageSize(PageSize.LETTER); document.open(); cb = writer.getDirectContent(); // Set basic metadata document.addAuthor("Peter Brewer"); document.addSubject("Tellervo Series Report for " + s.getDisplayTitle()); // Title Left ColumnText ct = new ColumnText(cb); ct.setSimpleColumn(document.left(), document.top() - 163, 283, document.top(), 20, Element.ALIGN_LEFT); ct.addText(getTitlePDF()); ct.go(); // Barcode ColumnText ct2 = new ColumnText(cb); ct2.setSimpleColumn(370, document.top(15) - 100, document.right(0), document.top(0), 20, Element.ALIGN_RIGHT); ct2.addElement(getBarCode()); ct2.go(); // Timestamp ColumnText ct3 = new ColumnText(cb); ct3.setSimpleColumn(document.left(), document.top() - 223, 283, document.top() - 60, 20, Element.ALIGN_LEFT); ct3.setLeading(0, 1.2f); ct3.addText(getTimestampPDF()); ct3.go(); // Authorship ColumnText ct4 = new ColumnText(cb); ct4.setSimpleColumn(284, document.top() - 223, document.right(10), document.top() - 60, 20, Element.ALIGN_RIGHT); ct4.setLeading(0, 1.2f); ct4.addText(getAuthorshipPDF()); ct4.go(); // Pad text document.add(new Paragraph(" ")); Paragraph p2 = new Paragraph(); p2.setSpacingBefore(50); p2.setSpacingAfter(10); p2.add(new Chunk(" ", bodyFont)); document.add(new Paragraph(p2)); // Ring width table getRingWidthTable(); document.add(getParagraphSpace()); if (s.getSeries() instanceof TridasMeasurementSeries) { // MEASUREMENT SERIES //document.add(getRingRemarks()); document.add(getWoodCompletenessPDF()); document.add(getParagraphSpace()); document.add(getSeriesComments()); document.add(getParagraphSpace()); document.add(getInterpretationPDF()); document.add(getParagraphSpace()); document.add(getElementAndSampleInfo()); } else { // DERIVED SERIES getWJTable(); document.add(getParagraphSpace()); document.add(getSeriesComments()); document.add(getParagraphSpace()); //document.add(getRingRemarks()); } } catch (DocumentException de) { System.err.println(de.getMessage()); } // Close the document document.close(); }
From source file:org.viafirma.util.QRCodeUtil.java
License:Apache License
/** * @param texto//from w ww . j a va 2 s . co m * Texto a colocar * @param textoQR * Imagen QR a colocar * @param codFirma * Cdigo de Firma a generar. * @param url Url del servicio de verificacin desde donde se puede descargar el documento. * @param document * Documeto destino * @param pageSize * Tamao de la pgina * @return * @throws BadElementException * @throws MalformedURLException * @throws IOException * @throws DocumentException * @throws ExcepcionErrorInterno */ private static float addContent(String texto, String url, String textoQR, String codFirma, Document document, Rectangle pageSize, boolean completo, boolean isSellado) throws BadElementException, MalformedURLException, IOException, DocumentException, ExcepcionErrorInterno { Image imagenCabezera = null; float widthCabecera = 0; float heightCabecera = 0; if (!isSellado) { // Recuperamos la imagen de cabecera imagenCabezera = Image.getInstance(QRCodeUtil.class.getResource(IMAGE_CABECERA)); // Colocamos la imagen en la zona superior de la pgina imagenCabezera.setAbsolutePosition(0, pageSize.getHeight() - imagenCabezera.getHeight()); heightCabecera = imagenCabezera.getHeight(); widthCabecera = imagenCabezera.getWidth(); } // Recuperamos el pie de firma Image imagenQR = Image.getInstance(QRCodeUtil.getInstance().generate(texto, url, textoQR, codFirma)); float rescalado = pageSize.getWidth() / (widthCabecera + document.leftMargin() + document.rightMargin()); float sizeCabecera = 0; if (rescalado < 1f && !isSellado) { // Requiere rescalado, la imagen es mayor que la pgina. imagenCabezera.scalePercent(rescalado * 100); sizeCabecera = rescalado * imagenCabezera.getHeight(); } float sizeCabecerayPie = HEIGHT_QR_CODE_PDF + sizeCabecera + document.bottomMargin() + document.topMargin() + SPACE_SEPARACION; // float escaleQR = HEIGHT_QR_CODE_PDF / (imagenQR.getHeight() + 5); float escaleQR = (pageSize.getWidth() - document.leftMargin() - document.rightMargin()) / (imagenQR.getWidth() + 6); // imagen.setSpacingAfter(120); if (!isSellado) { document.add(imagenCabezera); } // Aadimos una caja de texto si estamos mostrando el contenido del // fichero firmado. if (completo) { // Aadimos el espacio ocupado por la imagen Paragraph p = new Paragraph(""); p.setSpacingAfter(heightCabecera * rescalado); document.add(p); // Aadimos una tabla con borde donde colocar el documento. PdfPTable table = new PdfPTable(1); table.setWidthPercentage(100); table.getDefaultCell().setBorderWidth(10); PdfPCell celda = new PdfPCell(); celda.setFixedHeight(pageSize.getHeight() - sizeCabecerayPie); table.addCell(celda); table.setSpacingAfter(SPACE_SEPARACION); document.add(table); } if (completo) { // La imagen la colocamos justo debajo imagenQR.setAbsolutePosition(document.leftMargin(), escaleQR * HEIGHT_QR_CODE_PDF - SPACE_SEPARACION * 2); } else { imagenQR.setAbsolutePosition(document.leftMargin(), pageSize.getHeight() - sizeCabecerayPie); } imagenQR.scalePercent(escaleQR * 100); document.add(imagenQR); return sizeCabecerayPie; }