ulif.openoffice.convert – A Document Converter

A converter for office docs.

Run this script without arguments to get help.

It needs an openoffice server running in background.

Lots of this code was taken from the official OOo documentation for Python programmers.

ulif.openoffice.convert.convert(url='uno:socket, host=localhost, port=2002;urp;StarOffice.ComponentContext', filter_name='Text (Encoded)', extension='txt', paths=[])

Do the real conversion.

ulif.openoffice.convert.convert_file_to_html(url='uno:socket, host=localhost, port=2002;urp;StarOffice.ComponentContext', filter_name='HTML (StarWriter)', extension='html', filename=None, data=None)

Convert a file to HTML.

The function calls an OOo.org server in background to complete the task.

The filename and data arguments represent the name of the file to be converted and the contents of the file.

Returned is th path to a temporary directory, where the modified file and any subobjects (images, etc.) might reside.

It is in the resposibility of the calling code to remove the directory!

ulif.openoffice.convert.convert_to_html(url='uno:socket, host=localhost, port=2002;urp;StarOffice.ComponentContext', filter_name='HTML (StarWriter)', extension='html', path=None)

Convert the document in path to XHTML.

Returns the HTML text. Any subobjects are placed as files in the document path.

This function is not used in the psj packages, because it seems to suffer from race conditions when certain packages (namely Products.LinguaPlone) are used.

ulif.openoffice.convert.convert_to_pdf(url='uno:socket, host=localhost, port=2002;urp;StarOffice.ComponentContext', filter_name='writer_pdf_Export', extension='pdf', path=None)

Convert the document in path to PDF.

Returns the PDF document as string. Any subobjects are placed as files in the document path.

Previous topic

ulif.openoffice.client – The Client API

Next topic

ulif.openoffice.oooctl – A Daemon Controlling an OO.o-Server

This Page