private void appendTitle(ITextContext context, Paragraph preface) { if (StringUtils.isEmpty(title)) { return; } Styles styles = context.styles(); Font font = styles.getFont(FIRST_PAGE_TITLE_FONT).or(titleFont(styles)); Paragraph paragraph = null; for (String titlePart : title.split("[\n\r]+")) { paragraph = new Paragraph(titlePart, font); paragraph.setAlignment(Element.ALIGN_RIGHT); paragraph.setSpacingAfter(15.0f); preface.add(paragraph); } if (paragraph != null) { paragraph.setSpacingAfter(30.0f); } }
private void appendSubject(ITextContext context, Paragraph preface) { if (StringUtils.isEmpty(subject)) { return; } Styles styles = context.styles(); Font font = styles.getFont(FIRST_PAGE_SUBJECT_FONT).or(subjectFont(styles)); for (String titlePart : subject.split("[\n\r]+")) { Paragraph paragraph = new Paragraph(titlePart, font); paragraph.setAlignment(Element.ALIGN_RIGHT); paragraph.setSpacingAfter(15.0f); preface.add(paragraph); } }
for(Paragraph p : paraList){ p.setSpacingBefore(-3); p.setSpacingAfter(-3);
@Override public void process(int level, Node node, InvocationContext context) { List<Element> subs = context.collectChildren(level, node); Paragraph p = new Paragraph(); for (Element sub : subs) { p.add(discardNewline(sub)); } KeyValues kvs = context.iTextContext().keyValues(); Float spacingBefore = kvs.<Float>getNullable(PARAGRAPH_SPACING_BEFORE).or(5f); Float spacingAfter = kvs.<Float>getNullable(PARAGRAPH_SPACING_AFTER).or(5f); p.setSpacingBefore(spacingBefore); p.setSpacingAfter(spacingAfter); applyAttributes(context, p); context.append(p); }
if (e.type() == Element.LIST || e.type() == Element.PTABLE || e.type() == Element.PARAGRAPH) { if (tmp != null && tmp.size() > 0) { tmp.setSpacingAfter(0); list.add(tmp); tmp = cloneShallow(false); break; case Element.PARAGRAPH : ((Paragraph)lastElement).setSpacingAfter(getSpacingAfter()); break; case Element.LIST :
if (e.type() == Element.LIST || e.type() == Element.PTABLE || e.type() == Element.PARAGRAPH) { if (tmp != null && tmp.size() > 0) { tmp.setSpacingAfter(0); list.add(tmp); tmp = cloneShallow(false); break; case Element.PARAGRAPH : ((Paragraph)lastElement).setSpacingAfter(getSpacingAfter()); break; case Element.LIST :
if (value != null) { try { paragraph.setSpacingAfter(Float.parseFloat(value)); } catch (Exception e) {
if (value != null) { try { paragraph.setSpacingAfter(Float.parseFloat(value)); } catch (Exception e) {
@Override public void process(int level, Node node, InvocationContext context) { List<Element> subs = context.collectChildren(level, node); com.itextpdf.text.List orderedList = new com.itextpdf.text.List(com.itextpdf.text.List.ORDERED); for (Element sub : subs) { if (!orderedList.add(sub)) { // wrap it ListItem listItem = new ListItem(); listItem.add(sub); orderedList.add(listItem); } } KeyValues kvs = context.iTextContext().keyValues(); Float spacingBefore = kvs.<Float>getNullable(ORDERED_LIST_SPACING_BEFORE).or(5f); Float spacingAfter = kvs.<Float>getNullable(ORDERED_LIST_SPACING_AFTER).or(5f); Paragraph p = new Paragraph(); p.add(orderedList); p.setSpacingBefore(spacingBefore); p.setSpacingAfter(spacingAfter); context.append(p); } }
@Override public void process(int level, Node node, InvocationContext context) { List<Element> subs = context.collectChildren(level, node); com.itextpdf.text.List orderedList = new com.itextpdf.text.List(com.itextpdf.text.List.UNORDERED); orderedList.setListSymbol(context.bulletSymbol()); for (Element sub : subs) { if (!orderedList.add(sub)) { // wrap it ListItem listItem = new ListItem(); listItem.add(sub); orderedList.add(listItem); } } KeyValues kvs = context.iTextContext().keyValues(); Float spacingBefore = kvs.<Float>getNullable(BULLET_LIST_SPACING_BEFORE).or(5f); Float spacingAfter = kvs.<Float>getNullable(BULLET_LIST_SPACING_AFTER).or(5f); Paragraph p = new Paragraph(); p.add(orderedList); p.setSpacingBefore(spacingBefore); p.setSpacingAfter(spacingAfter); context.append(p); } }
/** * Constructs a <CODE>Paragraph</CODE> with a certain <CODE>Phrase</CODE>. * * @param phrase a <CODE>Phrase</CODE> */ public Paragraph(Phrase phrase) { super(phrase); if (phrase instanceof Paragraph) { Paragraph p = (Paragraph)phrase; setAlignment(p.alignment); setIndentationLeft(p.getIndentationLeft()); setIndentationRight(p.getIndentationRight()); setFirstLineIndent(p.getFirstLineIndent()); setSpacingAfter(p.getSpacingAfter()); setSpacingBefore(p.getSpacingBefore()); setExtraParagraphSpace(p.getExtraParagraphSpace()); setRole(p.role); id = p.getId(); if (p.accessibleAttributes != null) accessibleAttributes = new HashMap<PdfName, PdfObject>(p.accessibleAttributes); } }
/** * Constructs a <CODE>Paragraph</CODE> with a certain <CODE>Phrase</CODE>. * * @param phrase a <CODE>Phrase</CODE> */ public Paragraph(Phrase phrase) { super(phrase); if (phrase instanceof Paragraph) { Paragraph p = (Paragraph)phrase; setAlignment(p.alignment); setIndentationLeft(p.getIndentationLeft()); setIndentationRight(p.getIndentationRight()); setFirstLineIndent(p.getFirstLineIndent()); setSpacingAfter(p.getSpacingAfter()); setSpacingBefore(p.getSpacingBefore()); setExtraParagraphSpace(p.getExtraParagraphSpace()); setRole(p.role); id = p.getId(); if (p.accessibleAttributes != null) accessibleAttributes = new HashMap<PdfName, PdfObject>(p.accessibleAttributes); } }
protected void populateProperties(Paragraph copy, boolean spacingBefore) { copy.setFont(getFont()); copy.setAlignment(getAlignment()); copy.setLeading(getLeading(), multipliedLeading); copy.setIndentationLeft(getIndentationLeft()); copy.setIndentationRight(getIndentationRight()); copy.setFirstLineIndent(getFirstLineIndent()); copy.setSpacingAfter(getSpacingAfter()); if (spacingBefore) copy.setSpacingBefore(getSpacingBefore()); copy.setExtraParagraphSpace(getExtraParagraphSpace()); copy.setRole(role); copy.id = getId(); if (accessibleAttributes != null) copy.accessibleAttributes = new HashMap<PdfName, PdfObject>(accessibleAttributes); copy.setTabSettings(getTabSettings()); copy.setKeepTogether(getKeepTogether()); }
protected void populateProperties(Paragraph copy, boolean spacingBefore) { copy.setFont(getFont()); copy.setAlignment(getAlignment()); copy.setLeading(getLeading(), multipliedLeading); copy.setIndentationLeft(getIndentationLeft()); copy.setIndentationRight(getIndentationRight()); copy.setFirstLineIndent(getFirstLineIndent()); copy.setSpacingAfter(getSpacingAfter()); if (spacingBefore) copy.setSpacingBefore(getSpacingBefore()); copy.setExtraParagraphSpace(getExtraParagraphSpace()); copy.setRole(role); copy.id = getId(); if (accessibleAttributes != null) copy.accessibleAttributes = new HashMap<PdfName, PdfObject>(accessibleAttributes); copy.setTabSettings(getTabSettings()); copy.setKeepTogether(getKeepTogether()); }