public void TestReplace() { using (var fs = File.Open("./template.docx", FileMode.OpenOrCreate, FileAccess.ReadWrite)) using (var mould = new Mould(fs)) { var replacement = new Replacement(); replacement.Add("Field1", "Field1BlaBlaBla111"); replacement.Add("Field2", "Field2BlaBlaBla222"); replacement.Add("Field3", "Field3BlaBlaBla333"); mould.ReplaceField(replacement); mould.Save(); } }
public void TestReplaceAndRemovePartB() { using (var fs = File.Open("./template.docx", FileMode.OpenOrCreate, FileAccess.ReadWrite)) using (var mould = new Mould(fs)) { var removal = new Removal(); removal.Add("PartBStart", "PartBEnd"); mould.RemoveSection(removal); var replacement = new Replacement(); replacement.Add("Field1", "Field1BlaBlaBla111"); replacement.Add("Field2", "Field2BlaBlaBla222"); replacement.Add("Field3", "Field3BlaBlaBla333"); mould.ReplaceField(replacement); mould.Save(); } }
public void TestReplaceWithStyle() { using (var fs = File.Open("./template.docx", FileMode.OpenOrCreate, FileAccess.ReadWrite)) using (var mould = new Mould(fs)) { var replacement = new Replacement(); var style = new ReplaceStyle() { StrikeThrough = true, Bold = true, FontSize = 22 }; replacement.Add("Field1", "Field1BlaBlaBla111", style); replacement.Add("Field2", "Field2BlaBlaBla222"); replacement.Add("Field3", "Field3BlaBlaBla333"); mould.ReplaceField(replacement); mould.Save(); } }