public Section newSection(Paragraph sectionTitle, int hLevel, boolean numbered) { if (hLevel < 1) throw new IllegalArgumentException("Section hLevel starts at 1 (H1, H2, H3...)"); Arrays.fill(sections, hLevel, sections.length, null); Section section; if (hLevel == 1) { if (numbered) // only increase chapter number if the number is used chapterCount++; Chapter chapter = new Chapter(sectionTitle, chapterCount); sections[hLevel] = chapter; chapters.add(chapter); section = chapter; } else { Section parent = sections[hLevel - 1]; if (parent == null) { throw new IllegalStateException("No parent section (depth H" + (hLevel - 1) + ") found"); } sectionTitle.setSpacingBefore(20f); section = parent.addSection(10.0f, sectionTitle); sections[hLevel] = section; } if (!numbered) section.setNumberDepth(0); return section; }
this.setMaxWidth((int) ((currentMax) * chunk.getWidthPoint())); for(Paragraph p : paraList){ p.setSpacingBefore(-3); p.setSpacingAfter(-3);
private void printGraphDocumentation(Process process, Chapter chapter) throws Exception { Section section; String tmp; if (process.isEmbeddedProcess()) { String id = process.getAttribute(WorkAttributeConstant.LOGICAL_ID); if (id == null || id.length() == 0) id = process.getId().toString(); tmp = "Subprocess " + id + ": \"" + process.getName().replace('\n', ' ') + "\""; } else { tmp = "Process Description"; } Paragraph sTitle = new Paragraph(tmp, sectionFont); sTitle.setSpacingBefore(10); section = chapter.addSection(sTitle, 2); String summary = process.getDescription(); if (summary != null && summary.length() > 0) printBoldParagraphs(section, summary); String detail = process.getAttribute(WorkAttributeConstant.DOCUMENTATION); if (detail != null && detail.length() > 0) { printHtmlParagraphs(section, getHtmlContent(detail), 0); } if (!process.getAttributes().isEmpty() && process.isEmbeddedProcess()) { printAttributes(section, process.getAttributes(), 2); } }
@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 (value != null) { try { paragraph.setSpacingBefore(Float.parseFloat(value)); } catch (Exception e) {
if (value != null) { try { paragraph.setSpacingBefore(Float.parseFloat(value)); } catch (Exception e) {
break; case Element.PARAGRAPH: ((Paragraph) e).setSpacingBefore(getSpacingBefore()); break; case Element.LIST:
break; case Element.PARAGRAPH: ((Paragraph) e).setSpacingBefore(getSpacingBefore()); break; case Element.LIST:
@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); } }
p.setSpacingBefore(5f); if (!Strings.isNullOrEmpty(methodEntry.comment())) { List<Element> subs = context.emitButCollectElements(Markdown.from(methodEntry.comment()));
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()); }
public ColumnText generateTableOfContent(ITextContext context) { ColumnText ct = new ColumnText(null); Styles styles = context.styles(); Chunk CONNECT = connectChunk(styles); Paragraph paragraph = new Paragraph(); paragraph.setSpacingBefore(20.0f); // first paragraph only ct.addElement(new Paragraph("Table of content", styles.sectionTitleFontForLevel(1))); ct.addElement(new Paragraph("")); Font entryFont = styles.getFontOrDefault(TOC_ENTRY_FONT); TableOfContents tableOfContents = context.tableOfContents(); for (TableOfContents.Entry entry : tableOfContents.getEntries()) { //if (entry.isExtra()) // continue; Chunk chunk = new Chunk(entry.getText(), entryFont); paragraph.add(chunk); paragraph.add(CONNECT); paragraph.add(new Chunk("" + entry.getFormattedPageNumber(), entryFont)); float indent = 10.0f * entry.getLevel(); paragraph.setIndentationLeft(indent); ct.addElement(paragraph); paragraph = new Paragraph(); } return ct; }