Java Code Examples for com.lowagie.text.Paragraph#setSpacingAfter()
The following examples show how to use
com.lowagie.text.Paragraph#setSpacingAfter() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PdfDocumentFactory.java From javamelody with Apache License 2.0 | 6 votes |
Element createParagraphElement(String paragraphTitle, String iconName) throws DocumentException, IOException { final Paragraph paragraph = new Paragraph("", paragraphTitleFont); paragraph.setSpacingBefore(5); paragraph.setSpacingAfter(5); if (iconName != null) { paragraph.add(new Chunk(getParagraphImage(iconName), 0, -5)); } final Phrase element = new Phrase(' ' + paragraphTitle, paragraphTitleFont); element.setLeading(12); paragraph.add(element); // chapter pour avoir la liste des signets final ChapterAutoNumber chapter = new ChapterAutoNumber(paragraph); // sans numéro de chapitre chapter.setNumberDepth(0); chapter.setBookmarkOpen(false); chapter.setTriggerNewPage(false); return chapter; }
Example 2
Source File: SurveyPdf.java From JDeSurvey with GNU Affero General Public License v3.0 | 5 votes |
private void writeTitle(Document document,String title) throws Exception{ Paragraph titleParagraph = new Paragraph(title,titleFont); titleParagraph.setAlignment(Element.ALIGN_LEFT); titleParagraph.setLeading(30); titleParagraph.setSpacingAfter(2); document.add(titleParagraph); }
Example 3
Source File: StatisticsPdf.java From JDeSurvey with GNU Affero General Public License v3.0 | 5 votes |
private void writeTitle(Document document,String title) throws Exception{ Paragraph titleParagraph = new Paragraph(title,titleFont); titleParagraph.setAlignment(Element.ALIGN_LEFT); titleParagraph.setLeading(30); titleParagraph.setSpacingAfter(2); document.add(titleParagraph); }
Example 4
Source File: StatisticsPdf.java From JDeSurvey with GNU Affero General Public License v3.0 | 5 votes |
private void writeSubTitle(Document document,String title) throws Exception{ Paragraph titleParagraph = new Paragraph(title,subTitleFont); titleParagraph.setAlignment(Element.ALIGN_LEFT); titleParagraph.setLeading(20); titleParagraph.setSpacingAfter(2); document.add(titleParagraph); }
Example 5
Source File: MarkupParser.java From MesquiteCore with GNU Lesser General Public License v3.0 | 4 votes |
/** * Retrieves a Paragraph based on some style attributes. * @param font * @param styleattributes a Properties object containing keys and values * @return an iText Paragraph object */ public Element retrieveParagraph(Font font, Properties styleattributes) { Paragraph p = new Paragraph((Phrase)retrievePhrase(font, styleattributes)); if (styleattributes == null) return p; String margin = styleattributes.getProperty(MarkupTags.CSS_KEY_MARGIN); float f; if (margin != null) { f = parseLength(margin); p.setIndentationLeft(f); p.setIndentationRight(f); p.setSpacingBefore(f); p.setSpacingAfter(f); } margin = styleattributes.getProperty(MarkupTags.CSS_KEY_MARGINLEFT); if (margin != null) { f = parseLength(margin); p.setIndentationLeft(f); } margin = styleattributes.getProperty(MarkupTags.CSS_KEY_MARGINRIGHT); if (margin != null) { f = parseLength(margin); p.setIndentationRight(f); } margin = styleattributes.getProperty(MarkupTags.CSS_KEY_MARGINTOP); if (margin != null) { f = parseLength(margin); p.setSpacingBefore(f); } margin = styleattributes.getProperty(MarkupTags.CSS_KEY_MARGINBOTTOM); if (margin != null) { f = parseLength(margin); p.setSpacingAfter(f); } String align = styleattributes.getProperty(MarkupTags.CSS_KEY_TEXTALIGN); if (MarkupTags.CSS_VALUE_TEXTALIGNLEFT.equals(align)) { p.setAlignment(Element.ALIGN_LEFT); } else if (MarkupTags.CSS_VALUE_TEXTALIGNRIGHT.equals(align)) { p.setAlignment(Element.ALIGN_RIGHT); } else if (MarkupTags.CSS_VALUE_TEXTALIGNCENTER.equals(align)) { p.setAlignment(Element.ALIGN_CENTER); } else if (MarkupTags.CSS_VALUE_TEXTALIGNJUSTIFY.equals(align)) { p.setAlignment(Element.ALIGN_JUSTIFIED); } return p; }
Example 6
Source File: SoftLineBreakTest.java From itext2 with GNU Lesser General Public License v3.0 | 3 votes |
/** * Demonstrates adding a soft linebreak to a Paragraph * * */ @Test public void main() throws Exception { Document document = new Document(); RtfWriter2.getInstance(document, PdfTestBase.getOutputStream("SoftLineBreak.rtf")); document.open(); document.add(new Paragraph("This is just a paragraph.")); Paragraph par = new Paragraph(); // Set the spacings just to demonstrate that the soft linebreak // does not cause spacing before or after par.setSpacingBefore(10); par.setSpacingAfter(10); // Add the contents before the linebreak par.add("This paragraph contains a soft linebreak"); // Add the soft linebreak par.add(RtfDirectContent.DIRECT_SOFT_LINEBREAK); // Add the contents after the linebreak par.add("just before the just."); // Add the paragraph to the document document.add(par); document.add(new Paragraph("This is just a paragraph.")); document.close(); }