public static Paragraph CreateCaption(int count, string title, string caption, CaptionTypes captionType, string bookmarkId = null) { FieldCode fieldCode = null; if (captionType == CaptionTypes.Table) { fieldCode = new FieldCode(" SEQ Table \\* ARABIC "); } else if (captionType == CaptionTypes.Figure) { fieldCode = new FieldCode(" SEQ Figure \\* ARABIC "); } Paragraph p3 = new Paragraph( new ParagraphProperties( new ParagraphStyleId() { Val = Properties.Settings.Default.TableCaptionStyle }), DocHelper.CreateRun(caption), new Run( new FieldChar() { FieldCharType = new EnumValue <FieldCharValues>(FieldCharValues.Begin) }), new Run(fieldCode), new Run( new FieldChar() { FieldCharType = new EnumValue <FieldCharValues>(FieldCharValues.Separate) }), DocHelper.CreateRun(count.ToString(), bookmarkId), new Run( new FieldChar() { FieldCharType = new EnumValue <FieldCharValues>(FieldCharValues.End) }), DocHelper.CreateRun(": " + title)); return(p3); }
public static Paragraph CreateCaption(int count, string title, string caption, CaptionTypes captionType, string bookmarkId = null, HyperlinkTracker hyperlinkTracker = null) { FieldCode fieldCode = null; if (captionType == CaptionTypes.Table) { fieldCode = new FieldCode(" SEQ Table \\* ARABIC "); } else if (captionType == CaptionTypes.Figure) { fieldCode = new FieldCode(" SEQ Figure \\* ARABIC "); } Paragraph p3 = new Paragraph( new ParagraphProperties( new ParagraphStyleId() { Val = Properties.Settings.Default.TableCaptionStyle }) ); p3.Append( DocHelper.CreateRun(caption), new Run( new FieldChar() { FieldCharType = new EnumValue <FieldCharValues>(FieldCharValues.Begin) }), new Run(fieldCode), new Run( new FieldChar() { FieldCharType = new EnumValue <FieldCharValues>(FieldCharValues.Separate) }), DocHelper.CreateRun(count.ToString()), new Run( new FieldChar() { FieldCharType = new EnumValue <FieldCharValues>(FieldCharValues.End) }), DocHelper.CreateRun(": ")); var titleRun = DocHelper.CreateRun(title); if (!string.IsNullOrEmpty(bookmarkId)) { hyperlinkTracker.AddAnchorAround(p3, bookmarkId, titleRun); } else { p3.Append(titleRun); } return(p3); }