Aspose.Words用Aspose.Words.Range.Replace替换文本导出pdf
Posted 棉晗榜
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Aspose.Words用Aspose.Words.Range.Replace替换文本导出pdf相关的知识,希望对你有一定的参考价值。
使用Aspose.Words的方法:
namespace Aspose.Words
{
public class Range
{
public int Replace(string pattern, string replacement, FindReplaceOptions options);
}
}
string fileTempPath = AppDomain.CurrentDomain.BaseDirectory + "template/chengban_banzhong.doc";
Aspose.Words.Document doc = new Aspose.Words.Document(fileTempPath);
Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc);
Aspose.Words.Replacing.FindReplaceOptions options = new Aspose.Words.Replacing.FindReplaceOptions();
options.MatchCase = false;
//时间
doc.Range.Replace("@cui_ban_ri_qi", "2021-08-31", options);
// 督促检查事项
doc.Range.Replace("@matter","武松打虎", options);
//string path = "d:/SNQK_2.pdf";
//doc.Save(path, Aspose.Words.SaveFormat.Pdf);
//生成文件流,返回给浏览器
System.IO.MemoryStream stream = new System.IO.MemoryStream();
doc.Save(stream, Aspose.Words.SaveFormat.Pdf);
stream.Seek(0, System.IO.SeekOrigin.Begin);
word模板文件:
以上是关于Aspose.Words用Aspose.Words.Range.Replace替换文本导出pdf的主要内容,如果未能解决你的问题,请参考以下文章
Aspose.Words doc转pdf 内容出现丢失,页码跳页,排版混乱问题
Word处理控件Aspose.Words功能演示:使用 Aspose.Words for C++ 在 Qt 应用程序中创建 Word 文档