Exemplo n.º 1
0
        public void ReplaceAndAddWithImage()
        {
            using (WordServerDocument doc = new WordServerDocument())
            {
                File.Copy($"{s_BasePath}\\TemplateSample.docx", $"{s_BasePath}\\SampleImage.docx", true);

                Assert.AreEqual(doc.Open($"{s_BasePath}\\SampleImage.docx", out _), OutputCode.OK);


                Assert.AreEqual(doc.ReplaceTextWithStyle("REP01", "新潟県新潟市", true, new List <string>()
                {
                    "color:blue", "italic", "fontsize:24", "fontfamily:MS PMincho"
                }), 2);
                Assert.AreEqual(doc.ReplaceTextWithStyle("REP02", "中央区米山", true, new List <string>()
                {
                    "italic", "bold", "color:green", "fontfamily:MS PGothic"
                }), 1);
                Assert.AreEqual(doc.ReplaceTextWithImage("REP03", false, $"{s_BasePath}\\dos.png", 50, 50), 1);


                doc.AddText("製品企画室", new List <string>()
                {
                    "fontsize:110"
                });
                doc.AddText("TEL:", new List <string>()
                {
                    "italic"
                });
                doc.AddText("FAX:", new List <string>()
                {
                    "fontsize:54", "color:pink"
                });

                doc.Save();
            }
        }