public static Paragraph createParagraph(HashMap props) { Paragraph p = new Paragraph(); String value = (String) props.get("align"); if (value != null) { if (value.equalsIgnoreCase("center")) p.setAlignment(Element.ALIGN_CENTER); else if (value.equalsIgnoreCase("right")) p.setAlignment(Element.ALIGN_RIGHT); else if (value.equalsIgnoreCase("justify")) p.setAlignment(Element.ALIGN_JUSTIFIED); } setParagraphLeading(p, (String) props.get("leading")); return p; }
private static void setParagraphLeading(Paragraph p, String leading) { if (leading == null) { p.setLeading(0, 1.5f); return; } try { StringTokenizer tk = new StringTokenizer(leading, " ,"); String v = tk.nextToken(); float v1 = Float.valueOf(v).floatValue(); if (!tk.hasMoreTokens()) { p.setLeading(v1, 0); return; } v = tk.nextToken(); float v2 = Float.valueOf(v).floatValue(); p.setLeading(v1, v2); } catch (Exception e) { p.setLeading(0, 1.5f); } }
public static void createParagraph(Paragraph p, ChainedProperties props) { String value = props.getProperty("align"); if (value != null) { if (value.equalsIgnoreCase("center")) p.setAlignment(Element.ALIGN_CENTER); else if (value.equalsIgnoreCase("right")) p.setAlignment(Element.ALIGN_RIGHT); else if (value.equalsIgnoreCase("justify")) p.setAlignment(Element.ALIGN_JUSTIFIED); } setParagraphLeading(p, props.getProperty("leading")); value = props.getProperty("before"); if (value != null) { try { p.setSpacingBefore(Float.valueOf(value).floatValue()); } catch (Exception e) { } } value = props.getProperty("after"); if (value != null) { try { p.setSpacingAfter(Float.valueOf(value).floatValue()); } catch (Exception e) { } } value = props.getProperty("extraparaspace"); if (value != null) { try { p.setExtraParagraphSpace(Float.valueOf(value).floatValue()); } catch (Exception e) { } } }