/** * Constructs a Paragraph that will be used as title for a Section or Chapter. * @param title the title of the section * @param numbers a list of sectionnumbers * @param numberDepth how many numbers have to be shown * @param numberStyle the numbering style * @return a Paragraph object * @since iText 2.0.8 */ public static Paragraph constructTitle(final Paragraph title, final ArrayList<Integer> numbers, final int numberDepth, final int numberStyle) { if (title == null) { return null; } int depth = Math.min(numbers.size(), numberDepth); if (depth < 1) { return title; } StringBuffer buf = new StringBuffer(" "); for (int i = 0; i < depth; i++) { buf.insert(0, "."); buf.insert(0, numbers.get(i).intValue()); } if (numberStyle == NUMBERSTYLE_DOTTED_WITHOUT_FINAL_DOT) { buf.deleteCharAt(buf.length() - 2); } Paragraph result = new Paragraph(title); result.add(0, new Chunk(buf.toString(), title.getFont())); return result; }
/** * Constructs a Paragraph that will be used as title for a Section or Chapter. * @param title the title of the section * @param numbers a list of sectionnumbers * @param numberDepth how many numbers have to be shown * @param numberStyle the numbering style * @return a Paragraph object * @since iText 2.0.8 */ public static Paragraph constructTitle(final Paragraph title, final ArrayList<Integer> numbers, final int numberDepth, final int numberStyle) { if (title == null) { return null; } int depth = Math.min(numbers.size(), numberDepth); if (depth < 1) { return title; } StringBuffer buf = new StringBuffer(" "); for (int i = 0; i < depth; i++) { buf.insert(0, "."); buf.insert(0, numbers.get(i).intValue()); } if (numberStyle == NUMBERSTYLE_DOTTED_WITHOUT_FINAL_DOT) { buf.deleteCharAt(buf.length() - 2); } Paragraph result = new Paragraph(title); result.add(0, new Chunk(buf.toString(), title.getFont())); return result; }
result.add( 0, new Chunk( buf.toString(), title.getFont() ) ); return result;
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()); }