Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Bridging Python, Web and LibreOffice

License

NotificationsYou must be signed in to change notification settings

ulif/ulif.openoffice

Repository files navigation

Convert office docs with LibreOffice/OpenOffice via Python,Commandline, or HTTP (including XMLRPC).

build-status

This package provides tools like WSGI apps, cache managers, andcommandline converters to ease access to LibreOffice/OpenOfficeinstallations for Python programmers. Beside basic converting itprovides 'document processors' for further finetuning of generateddocs (mainly HTML).

Out of the box these processors allow extracting CSS from HTMLconversions, removal of LibreOffice-specific tags, zipping, unzipping,etc.

If the given processors are not enough for you, or you want somespecial handling of results (say, sign generated docscryptographically, add watermarks, or whatever), you can define ownadditional document processors in your own packages by using thePython entry-point API. ulif.openoffice will integrate themautomatically during document processing and provide them inwebservices, commandline clients and Python API.

Note

ulif.openoffice trusts unoconv to do the actualconversions. So you must have the unoconv script installedon your system.

ulif.openoffice sources are hosted on

https://github.com/ulif/ulif.openoffice

The complete documentation can be found at

https://ulif-openoffice.readthedocs.io/en/latest/

A .doc to .html conversion via the Python API can be done like this:

>>> from ulif.openoffice.client import Client>>> client = Client()>>> result = client.convert('document.doc')>>> pprint(result)('.../document.html.zip', None, {'error': False, 'oocp_status': 0})

The generated document is by default brushed up HTML with separatestylesheets and images all put into a single .zip document.

You can configure the document conversion via various options. Thisway you can set the output type (at least PDF, HTML, XHTML and TXT aresupported), tell whether separate CSS stylesheets should be extracted,which PDF format should be generated (1.3 aka PDF/A or 1.4), and many,many things more.

We also provide a handy commandline tool to perform conversions:

$ oooclient document.docRESULT in /tmp/.../document.html.zip

As you can see, the result is put in a freshly created directory.

The commandline client also provides help to display all supportedoptions, document processors, etc.:

$ oooclient --help

will give you the comprehensive list.

ulif.openoffice comes with two WSGI applications that providedocument conversion services to web clients. One is a RESTful documentconversion service, the other is a WSGI based XMLRPC server. With oneof these applications running you can send office documents to aserver and will receive the converted document.

All WSGI document converters supports (optional) local caching whichwill store conversion results and deliver it (bypassing newconversion) if a document was requested to be converted already.

The package comes with prepared configuration files to setup and startsuch a web-based document converter in minutes.

See the extended docs under

https://ulif-openoffice.readthedocs.io/en/latest/

for details.

ulif.openoffice can be installed via pip:

$ pip install ulif.openoffice

Afterwards all commandline tools should be available.

It is recommended to setup sources in a virtual environment:

$ virtualenv py27      # Python 2.6, 2.7 are supported$ source py27/bin/activate(py27) $

Get the sources:

(py27) $ git clone https://github.com/ulif/ulif.openoffice.git(py27) $ cd ulif.openoffice

Install packages for testing:

(py27) $ python setup.py dev

It is recommended to start theoooctl daemon before runningtests:

(py27) $ oooctl start

This will make LibreOffice listen in background and reduceruntime of tests significantly.

Running tests:

(py27) $ py.test

We also support tox to run tests for all supported Python versions:

(py27) $ pip install tox(py27) $ tox

Of course you must have the respective Python versions installed(currently: Python 2.6, 2.7).

Running coverage detector:

(py27) $ py.test --cov=ulif.openoffice    # for cmdline results(py27) $ py.test --cov=ulif.openoffice --cov-report=html

The latter will generate HTML coverage reports in a subdirectory.

Install packages for Sphinx-base documentation:

(py27) $ python setup.py docs(py27) $ cd doc(py27) $ make html

Will generate the documentation in a subdirectory.

ulif.openoffice is covered by the GPL version 2.

By Uli Fouquet (uli at gnufix dot de). Please do not hesitate tocontact me for wishes, requests, suggestions, or other questions.

About

Bridging Python, Web and LibreOffice

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp