admin管理员组文章数量:1536065
2024年3月19日发(作者:)
Batch processing with OpenOffice
MS did a big job spreading office format worldwide. It is almost everywhere, tons,
millions of files. Often it is needed to automate processing of this files. One way is to
go with MS Office with VBA or OLE automation, this requires license for office
and win32 system as well. Other way is to go with Open Office, which is free and
reliable.
OpenOffice has nice batch processing features which no competitors have. About them
I want to tell today. I would call this feature unattended usage or open office batch
procesing. And it rocks.
Strong points of OpenOffice are
Works on Windows OS family as well as Linux OS
Can open A LOT of file formats
It can save to many file formats
It can run Macros, even VBA with http://go-oo.org
Typical applications are
Imagine you have to index 1000 doc document ?
Or upload excel table to site and extract all data from it ?
Or convert 10000 document to PDF ?
OpenOffice batch usage
Lets try something simple at first time, for example how to convert DOC to PDF ?
Here is example using Office 3.1 for how to convert from MS Word DOC to Adobe PDF.
Run OpenOffice and open in main menu Tools -> Macro -> Organize Dialog -> Modules
-> My Macros
Click New button and choose name: Module1.
Insert this code into module and save
Sub SaveAsPDF( cFile )
Dim oPropertyValue As New com.sun.star.beans.PropertyValue
cURL = ConvertToURL( cFile )
' Open file
oPropertyValue.Name = "Hidden"
oPropertyValuue = True
oDoc = StarDesktop.loadComponentFromURL( cURL, "_blank", 0, _
Array(oPropertyValue,))
' Generate PDF name in same directory
cFile = Left( cFile, Len( cFile ) - 4 ) + ".pdf"
cURL = ConvertToURL( cFile )
' Save the document using a filter.
oPropertyValme = "FilterName"
oPropertyValue.Value = "writer_pdf_Export"
oDoc.storeToURL( cURL, Array(oPropertyValue))
oDose( True )
End Sub
To execute this macro in unattended mode run this command:
soffie -invisible "macro:///Standarule1.SaveAsPDF(c:sample.doc)"
Check c: it should contain sampl
Thats it!
You can use your editor for macros, Macro files are stored XML files, for
windows look for them in
c:Document and SettingsApplication DataOpenOffig3userbasicStandart
Same method works in Linux. You can do it on headless server.
This is simple case. If you want to dive deeper try to google for UNO.
===============================
用java把MS office转成pdf
2011-03-18 16:50:04| 分类: Jod2S |字号 订阅
引自:梦女孩
先用openOffice把ppt、word、excel、txt转换成pdf,然后用swftools转换成
swf,然后在线播放。
具体说明如下(windows,在linux下偶正准备测试)
版权声明:本文标题:使用openoffice转换为pdf格式 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://m.elefans.com/dianzi/1710801302a284189.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论