zoukankan      html  css  js  c++  java
  • Word 转换为 PDf 的技术方案

    1. ntko office control 内置的TANGER_OCX_OBJ.SaveAsPDFFile接口方法(保存客户端)和TANGER_OCX_OBJ.PublishAsPDFToURL接口方法(保存服务器端)。

    2. 2007 office save as pdf 插件另存pdf的方式。

    public bool SaveToPDF(string WordPath, string PDFPath)
            {
                Microsoft.Office.Interop.Word.Application WordApp = new Microsoft.Office.Interop.Word.ApplicationClass();
                Document WordDoc = null;
                Object Nothing = System.Reflection.Missing.Value;
                object  Readonly = true;
                object wordpathobj = WordPath;
                try
                {
                    WordDoc = WordApp.Documents.Open(ref wordpathobj, ref Nothing,ref Readonly, ref Nothing, ref Nothing,
                         ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing,
                         ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing);
                    WordDoc.ExportAsFixedFormat(PDFPath, WdExportFormat.wdExportFormatPDF, false,
                        WdExportOptimizeFor.wdExportOptimizeForPrint, WdExportRange.wdExportAllDocument, 1, 1,
                        WdExportItem.wdExportDocumentContent, true, true, WdExportCreateBookmarks.wdExportCreateWordBookmarks,
                        true, true, true, ref Nothing);
                    return true;
                }
                catch (Exception ex)
                {
                    Common.LogEIAC.Error(ex.ToString());
                    return false;
                    //throw ex;
                }
                finally
                {
                    if (WordDoc != null) WordDoc.Close(ref Nothing, ref Nothing, ref Nothing);
                    WordApp.Quit(ref Nothing, ref Nothing, ref Nothing);
                }
            }


    插件地址:

    2007 Microsoft Office Add-in: Microsoft Save as PDF

    http://www.microsoft.com/downloads/details.aspx?FamilyId=F1FC413C-6D89-4F15-991B-63B07BA5F2E5&displaylang=en


    3. 先调用打印机打印输出postscript文件,再调用acrobat Distiller 接口转换为pdf, 此方法去年年中曾经尝试过, 需要同时配置word和acrobat distiller的com+启动、执行权限,环境配置相对繁琐。

    原文参考:
    http://blog.csdn.net/zerodj/archive/2006/02/23/607610.aspx


    4. 另外可以尝试调用pdf creator 的接口进行转换, 缺点是这个软件的兼容性和稳定性不够好, 这个方案没有进行过验证。

  • 相关阅读:
    Spring实践第三天 (SpringDI:依赖注入)
    单例模式(Singleton)
    Spring IOC 及 Spring 中Bean的三种创建方式
    Spring实践第二天(创建对象的三种基本方式)
    ORA-28374: typed master key not found in wallet
    Unable open dabase as spfile parameter incorrect
    【java/C# 服务器】IOS 配置推送证书 p12文件流程
    第一贱-UILabel
    iOS开发系列--让你的应用“动”起来
    AFNetworking 使用总结
  • 原文地址:https://www.cnblogs.com/snowlove67/p/1399186.html
Copyright © 2011-2022 走看看