如何解决打开RTF文件时出现安全警告
我已将多个RTF文件合并为一个RTF文件,并保存了单个RTF文件。多个RTF文件中包含图像。我已使用Interop.word Microsoft Office库将多个RTF文件合并为一个RTF文件。当我尝试使用写字板打开该Single RTF文件时,它显示安全警告,并要求“取消阻止”和“阻止”内容。单个RTF文件中包含图片。打开RTF文件时,它不信任RTF文件中的图像内容。
我使用了这个Nuget软件包:
Microsoft.Office.Interop.Word-版本15.0.4797.1003
public static void Merge(string[] filesToMerge,string outputFilename,bool insertPageBreaks)
{
object missing = System.Type.Missing;
object pageBreak = Microsoft.Office.Interop.Word.WdBreakType.wdSectionBreakNextPage;
object outputFile = outputFilename;
Microsoft.Office.Interop.Word._Application wordApplication = new Microsoft.Office.Interop.Word.Application();
try
{
Microsoft.Office.Interop.Word.Document wordDocument = wordApplication.Documents.Add(
ref missing,ref missing,ref missing);
Microsoft.Office.Interop.Word.Selection selection = wordApplication.Selection;
int documentCount = filesToMerge.Length;
int breakStop = 0;
foreach (string file in filesToMerge)
{
breakStop++;
selection.InsertFile(file,ref missing);
if (insertPageBreaks && breakStop != documentCount)
{
selection.InsertBreak(ref pageBreak);
}
}
wordDocument.SaveAs(
ref outputFile,ref missing);
wordDocument = null;
}
catch (Exception ex)
{
throw ex;
}
finally
{
wordApplication.Quit(ref missing,ref missing);
}
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。