/// <summary> /// Add field replacement.If field already existed old value will be replaced. /// </summary> /// <param name="fieldName"></param> /// <param name="value"></param> /// <param name="style"></param> public void Add(string fieldName, string value, ReplaceStyle style = null) { var key = this.FieldKey(fieldName); var replaceValue = new ReplaceValue() { Value = value, Style = style }; if (this._dict.ContainsKey(key)) { this._dict[key] = replaceValue; } else { this._dict.Add(key, replaceValue); } }
private void SetCustomerStyle(Run run, ReplaceStyle style) { if (style == null) { return; } if (string.IsNullOrEmpty(style.FontFamily)) { run.RunProperties.RunFonts = new RunFonts() { Ascii = style.FontFamily } } ; if (style.FontSize != null) { run.RunProperties.FontSize = new FontSize() { Val = new StringValue(style.FontSize.ToString()) } } ; if (style.Bold != null) { run.RunProperties.Bold = new Bold() { Val = new OnOffValue(style.Bold.Value) } } ; if (style.Capitalized != null) { run.RunProperties.Caps = new Caps() { Val = new OnOffValue(style.Capitalized.Value) } } ; if (style.DoubleStrikeThrough != null) { run.RunProperties.DoubleStrike = new DoubleStrike() { Val = new OnOffValue(style.DoubleStrikeThrough.Value) } } ; if (style.Embossed != null) { run.RunProperties.Emboss = new Emboss() { Val = new OnOffValue(style.Embossed.Value) } } ; if (style.Imprinted != null) { run.RunProperties.Imprint = new Imprint() { Val = new OnOffValue(style.Imprinted.Value) } } ; if (style.Italic != null) { run.RunProperties.Italic = new Italic() { Val = new OnOffValue(style.Italic.Value) } } ; if (style.Shadowed != null) { run.RunProperties.Shadow = new Shadow() { Val = new OnOffValue(style.Shadowed.Value) } } ; if (style.SmallCaps != null) { run.RunProperties.SmallCaps = new SmallCaps() { Val = new OnOffValue(style.SmallCaps.Value) } } ; if (style.StrikeThrough != null) { run.RunProperties.Strike = new Strike() { Val = new OnOffValue(style.StrikeThrough.Value) } } ; if (style.VerticalPosition != null) { run.RunProperties.VerticalTextAlignment = new VerticalTextAlignment() { Val = (VerticalPositionValues)style.VerticalPosition.Value } } ; }