線上訂房服務-台灣趴趴狗聯合訂房中心
發文 回覆 瀏覽次數:3615
推到 Plurk!
推到 Facebook!

如何利用OpenOffice的功能把 txt or doc or xls 轉成.pdf檔 ?

 
christie
資深會員


發表:30
回覆:299
積分:475
註冊:2005-03-25

發送簡訊給我
#1 引用回覆 回覆 發表時間:2008-03-21 11:46:41 IP:203.73.xxx.xxx 未訂閱
如何利用OpenOffice的功能把txt or doc or xls 轉.pdf檔?
1. OpenOffice 的 Writer [工具] -> [巨集] -> [組織對話]
選 [模塊] 頁籤
點 Module1 按編輯。
2. 把 REM *** Basic ***
Sub Main
End Sub 段,
置換為
REM ***** BASIC ***** 97.3.21

Sub ConvertWordToPDF(cFile)
cURL = ConvertToURL(cFile)

' 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), ))

cFile = Left(cFile, Len(cFile) - 4) ".pdf"
cURL = ConvertToURL(cFile)

' 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

3. 新資料夾
C:\TXT2PDF
4. 一個批次檔
cvt2pdf.bat
Rem cvt2pdf.bat %1 97.3.21
@ECHO OFF
"c:\program files\OpenOffice.org 2.2\program\soffice" -invisible "macro:///Standard.Module1.ConvertWordToPDF(%1)"
Rem 若您的OpenOffice是2.1版,就把2.2改成2.1。
5. 執行 C:\TXT2PDF
指令
cvt2pdf.bat myTest.txt

就可產生 myTest.pdf 。
------
What do we live for if not to make life less difficult for each other?
系統時間:2024-05-15 16:04:34
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!