Exemple #1
0
 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();
         }
 }
Exemple #2
0
        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();
                }
        }
Exemple #3
0
 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();
         }
 }