whueuwe 2023-05-16 08:22 采纳率: 100%
浏览 14
已结题

vs2012+office2007 word转pdf字体缺失

vs2012+office2007 word转pdf字体缺失 vs运行可以,部署到IIS字体缺失,有遇到过这种情况吗?

 public static bool WordToPdf(string sourcePath, string targetPath)
        {



            bool result = false;

            Microsoft.Office.Interop.Word.WdExportFormat wdExportFormatPDF = Microsoft.Office.Interop.Word.WdExportFormat.wdExportFormatPDF;//转换格式1.wdExportFormatPDF转换成pdf格式 2.wdExportFormatXPS转换成xps格式

            object missing = Type.Missing;

            Microsoft.Office.Interop.Word.ApplicationClass applicationClass = null;

            Microsoft.Office.Interop.Word.Document document = null;

            try
            {

                applicationClass = new Microsoft.Office.Interop.Word.ApplicationClass();

                object inputfileName = sourcePath;//需要转格式的文件路径

                string outputFileName = targetPath;//转换完成后PDF或XPS文件的路径和文件名名称

                WdExportFormat exportFormat = wdExportFormatPDF;//导出文件所使用的格式

                bool openAfterExport = false;//转换完成后是否打开

                WdExportOptimizeFor wdExportOptimizeForPrint = WdExportOptimizeFor.wdExportOptimizeForPrint;//导出方式1.wdExportOptimizeForPrint针对打印进行导出,质量较高,生成的文件大小较大。2.wdExportOptimizeForOnScreen 针对屏幕显示进行导出,质量较差,生成的文件大小较小。

                WdExportRange wdExportAllDocument = WdExportRange.wdExportAllDocument;//导出全部内容(枚举)

                int from = 0;//起始页码

                int to = 0;//结束页码

                WdExportItem wdExportDocumentContent = WdExportItem.wdExportDocumentContent;//指定导出过程中是否只包含文本或包含文本的标记.1.wdExportDocumentContent:导出文件没有标记,2.导出文件有标记

                bool includeDocProps = true;//指定是否包含新导出的文件在文档属性

                bool keepIRM = true;//

                WdExportCreateBookmarks wdExportCreateWordBookmarks = WdExportCreateBookmarks.wdExportCreateWordBookmarks;//1.wdExportCreateNoBookmarks:不要在导出文件中创建书签,2.wdExportCreateHeadingBookmarks:标题和文本框导出的文件中创建一个书签,3.wdExportCreateWordBookmarks每个字的书签,其中包括除包含页眉和页脚中的所有书签导出的文件中创建一个书签。

                bool docStructureTags = true;

                bool bitmapMissingFonts = true;

                bool UseISO19005_1 = false;//生成的文档是否符合 ISO 19005-1 (PDF/A)

                document = applicationClass.Documents.Open(ref inputfileName, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing);

                if (document != null)
                {

                    document.ExportAsFixedFormat(outputFileName, exportFormat, openAfterExport, wdExportOptimizeForPrint, wdExportAllDocument, from, to, wdExportDocumentContent, includeDocProps, keepIRM, wdExportCreateWordBookmarks, docStructureTags, bitmapMissingFonts, UseISO19005_1, ref missing);

                }

                result = true;

            }

            catch
            {

                result = false;

            }

            finally
            {

                if (document != null)
                {

                    document.Close(ref missing, ref missing, ref missing);

                    document = null;

                }

                if (applicationClass != null)
                {

                    applicationClass.Quit(ref missing, ref missing, ref missing);

                    applicationClass = null;

                }

            }

            return result;

        }

  • 写回答

1条回答 默认 最新

  • threenewbee 2023-05-16 08:51
    关注

    你的word文件保存的时候,选择内嵌下ttf字体

    img

    如图所示。

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

问题事件

  • 系统已结题 7月6日
  • 已采纳回答 6月28日
  • 创建了问题 5月16日

悬赏问题

  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100