使用Interop.Word将Word转换为PDF时文档绘图消失的问题求助
Word通过Office Interop转PDF后内置绘图丢失问题
我有一份Word文件,其中包含若干绘图,转换前Word文件内绘图正常显示。
但当我将该文件转换为PDF后,这些绘图全部消失,转换后的PDF文件无对应绘图内容。
我的实现代码如下:
string path2document = physical_path; string path2pdf = physical_path.Replace(file_type, ".pdf"); var appWord = new Microsoft.Office.Interop.Word.Application(); var wordDocument = appWord.Documents.Open(path2document, ReadOnly: true); var numberOfPages = wordDocument.ComputeStatistics(WdStatistic.wdStatisticPages, false); if (System.IO.File.Exists(path2pdf) == false && numberOfPages <= 100) { // 可任选以下一种转换方法 wordDocument.ExportAsFixedFormat(path2pdf, Microsoft.Office.Interop.Word.WdExportFormat.wdExportFormatPDF); // 或 wordDocument.SaveAs2(path2pdf, Microsoft.Office.Interop.Word.WdSaveFormat.wdFormatPDF); } if (wordDocument != null) { wordDocument.Close(WdSaveOptions.wdDoNotSaveChanges); } if (appWord != null) { appWord.Quit(WdSaveOptions.wdDoNotSaveChanges); appWord = null; } wordDocument.Close(); appWord.Quit();
我同时尝试了SaveAs2和ExportAsFixedFormat两种转换方法,得到的结果一致,PDF文件中均不显示原Word里的绘图。恳请各位帮忙解决该问题,提前致谢。
补充说明:我在服务器上使用的是Microsoft Office Profession Plus 2013版本。
内容的提问来源于stack exchange,提问作者beginner_coder
相关产品推荐
相关产品推荐

