使用OpenOffice .org(Portable)将WORD转换为PDF

原文地址:

http://www.codeproject.com/Articles/15846/Converting-Microsoft-Word-Document-to-PDF-format-u


步骤:

1. 下载OpenOffice.org

       http://portableapps.com/apps/office/openoffice_portable


2.  配置OpenOffice.org

     1) 启动OpenOfficePortable.exe工具,不用注册(需要填写一些用户信息,但是不需要注册)

     2) 修改Marco标识

         a。选择“Tools->Macros->Organize Macros->OpenOffice.org Basic”              

OpenOffice.org main window

         b。选择 "Organizer..."后创建一个新的tab Libraries,  并且命名为 "ConversionLibrary"

Create the new library

         c。创建完成后,切换至Modules tab, 选择 "ConversionLibrary", 创建一个新的模块并命名为 "PDFConversion"

create the new module

         d。创建完成后,选择“PDFConversion”,然后选择“Edit”按钮,将以下代码拷贝进去

REM  *****  BASIC  *****
Sub ConvertWordToPDF( cSourceFile , cDestinationFile)
   cURL = ConvertToURL( cSourceFile )
   ' Open the document.
   ' Just blindly assume that the document
   ' is of a type that OOo will
   '  correctly recognize and open -- 
   '   without specifying an import filter.

   oDoc = StarDesktop.loadComponentFromURL( cURL, "_blank", 0, _
          Array(MakePropertyValue( "Hidden", True ),) )

   cURL = ConvertToURL( cDestinationFile )
   
   ' Save the document using a filter.   
   oDoc.storeToURL( cURL, _
     Array(MakePropertyValue( "FilterName", "writer_pdf_Export" ),)
   
   oDoc.close( True )
End Sub

Function MakePropertyValue( Optional cName As String, _
         Optional uValue ) As com.sun.star.beans.PropertyValue
   Dim oPropertyValue As New com.sun.star.beans.PropertyValue
   If Not IsMissing( cName ) Then
      oPropertyValue.Name = cName
   EndIf
   If Not IsMissing( uValue ) Then
      oPropertyValue.Value = uValue
   EndIf
   MakePropertyValue() = oPropertyValue
End Function 
         e。至此,工具编辑完成。

         f。演示DEMO见如下地址

              http://download.csdn.net/detail/wangyong0921/4824679

        g。如果你命名的规则如上述步骤不一样(包括库名称,模块名称,Marco名称),那么你需要手动修改一下应用程序配置文件(UsingOpenOffice.exe.config



  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值