欢迎光临
我们一直在努力

c#中怎么利用Aspose打印Word - 编程语言

这篇文章给大家介绍c#中怎么利用Aspose打印Word,内容非常详细,感兴趣的小伙伴们可以参考借鉴,希望对大家能有所帮助。

创建域

以word2013为例,插入-文本-文档部件-域,选择MergeField

下图示例就是插入域完毕的文档

使用Aspose.Word

注册Aspose.Words 去水印

        string licenseFile = System.IO.Path.Combine(ModelPath, @"Model\Aspose.Words.lic");
            if (File.Exists(licenseFile))
            {
                Aspose.Words.License license = new Aspose.Words.License();
                license.SetLicense(licenseFile);
            }

域替换

Document doc = new Document(System.IO.Path.Combine(ModelPath, TempWordName));
            DocumentBuilder builder = new DocumentBuilder(doc);

            if (titleField != null && valueField != null)
                //文档域的字段赋值
                doc.MailMerge.Execute(titleField, valueField);

            doc.Save(SavePath + ExportWordName);

关于c#中怎么利用Aspose打印Word就分享到这里了,希望以上内容可以对大家有一定的帮助,可以学到更多知识。如果觉得文章不错,可以把它分享出去让更多的人看到。

赞(0)
【声明】:本博客不参与任何交易,也非中介,仅记录个人感兴趣的主机测评结果和优惠活动,内容均不作直接、间接、法定、约定的保证。访问本博客请务必遵守有关互联网的相关法律、规定与规则。一旦您访问本博客,即表示您已经知晓并接受了此声明通告。