PyODConverter-文檔轉換

來源:互聯網
上載者:User

PyODConverter
PyODConverter, for Python OpenDocument Converter, is a Python script that automates office

document conversions from the command line using OpenOffice.org.

The script does basically the same thing as the command line tool that comes with JODConverter

but is much simpler. In fact the Python script was released for the people who use JODConverter

only from the command line (not as a Java library or web service) and would like a simpler

alternative.

是一個使用openoffice.org從命令列下轉換文檔的python指令碼
這個指令碼能更簡單的實現和JODConverter想通在命令列下的基本轉換;事實上,它的發布是為了那些只在命令

行下使用JODConverter的人們(而不是一個java庫或者一個web服務)。它將是一個簡單的替代方案。

Usage
Just like JODConverter, PyODConverter requires OpenOffice.org to be running as a service and

listening on port (by default) 8100; the simples way to start OpenOffice.org as a service is

from the command line

> "C:\Program Files\OpenOffice.org 2.2\program\soffice" -accept="socket,port=8100;urp;"
The script expects exactly 2 parameters: an input and an output file names. The document formats

are inferred from the file extensions.

Since it uses the Python/UNO bridge, the script requires the UNO modules to be already present

in your Python installation. Most of the time this means you need to use the Python version

installed with OpenOffice.org, e.g. on Windows

> "C:\Program Files\OpenOffice.org 2.2\program\python" DocumentConverter.py test.odt test.pdf
or on Linux

$ /opt/openoffice.org2.2/program/python DocumentConverter.py test.PPT test.pdf

用法:
同JODConverter一樣,PyODConverter需要Openoffice.org作為一個服務監聽一個連接埠(預設的是8100),從

命令列下啟動服務最簡單的方法如下:
for windows:
>"c:\Program Files\OpenOffice.org 2.3\program\soffice" -accept="socket,port=8100;urp;"

因為該使用python-UNO橋,要運行PyODConverter你需要安裝pyhon的時候安裝了UNO模組,大多數情況下當你

安裝OpenOfiice.org的時候附帶安裝的python就可以。(通過Python-UNO橋,您可以通過Python使用標準的

OpenOffice.org API. 同時允許您使用Python編寫UNO組建,這樣python UNO 組建可以在Office進程中運行,

而且可被Java, C++ 和StarBisic指令碼調用.)

這個指令碼有兩個必要的參數:一個輸入檔案名稱和一個輸出檔案名,文檔的類型取決於檔案的副檔名
在windows上:
> "C:\Program Files\OpenOffice.org 2.2\program\python" DocumentConverter.py test.odt test.pdf

在linux上,命令如下:
$ /opt/openoffice.org2.3/program/python DocumentConverter.py test.ppt test.pdf
注意DocumentConverter.py的路徑,PyODConverter也可以用做python module,用於你自己的指令碼。如下我將它用於php指令碼

>vi convert.php

<?php

   system("/opt/openoffice.org3/program/python DocumentConverter.py test.ppt test.swf");
?>

>/usr/local/php5/bin/php convert.php

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.