/** * 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(Paragraph title, List <int> numbers, int numberDepth, int numberStyle) { if (title == null) { return(null); } int depth = Math.Min(numbers.Count, numberDepth); if (depth < 1) { return(title); } StringBuilder buf = new StringBuilder(" "); for (int i = 0; i < depth; i++) { buf.Insert(0, "."); buf.Insert(0, numbers[i]); } if (numberStyle == NUMBERSTYLE_DOTTED_WITHOUT_FINAL_DOT) { buf.Remove(buf.Length - 2, 1); } Paragraph result = new Paragraph(title); result.Insert(0, new Chunk(buf.ToString(), title.Font)); 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(Paragraph title, ArrayList numbers, int numberDepth, int numberStyle) { if (title == null) { return null; } int depth = Math.Min(numbers.Count, numberDepth); if (depth < 1) { return title; } StringBuilder buf = new StringBuilder(" "); for (int i = 0; i < depth; i++) { buf.Insert(0, "."); buf.Insert(0, (int)numbers[i]); } if (numberStyle == NUMBERSTYLE_DOTTED_WITHOUT_FINAL_DOT) { buf.Remove(buf.Length - 2, 1); } Paragraph result = new Paragraph(title); result.Insert(0, new Chunk(buf.ToString(), title.Font)); return result; }