Module to generate OpenOffice Writer documents

Erwin S. Andreasen erwin at andreasen.com
Sat Sep 20 16:45:11 CEST 2003


python <python at sarcastic-horse.com> writes:

> On Wed, 17 Sep 2003 19:53:15 -0400
> "Ellinghaus, Lance" <lance.ellinghaus at eds.com> wrote:
> 
> > Has anyone created a module to generate the XML formatted files for
> > OpenOffice?
> > 
> 
> Sorry, I can't help you there.
> 
> What I'd be even more interested in is if it is possible to submit the
> xml to OpenOffice, and then use its rendering features to crank out
> pretty PDF files, all through scripts.

I do almost exactly that, though the output is Power Point rather than
PDF.

I originally wanted to do this using the Python UNO API but that
proved somewhat difficult to use (although the Office Basic API is
also horrible).

So all I do is to generate a OO XML file, stick it in a fixed location
then call:
  soffice -display :1 macro:///Standard.Module1.NewConvert

where the Standard.Module1.NewConvert macro is one that opens the
file, saves as PPT and closes the document again (the macro is easy
enough to generate using the macro recording feature).

The display at :1 is a virtual framebuffer (xvfb) where OpenOffice is
running -- calling soffice if it is already running asks the main
program to synchronously run the macro and the soffice command exits
once the main program is done with its execution.

As for the XML input file: I generate most of it by hand. I started
out by generating everything to the specs I wanted (styles, etc.) and
saving that file. The .SX? files are just ZIP files, with the the
content stored in the 'content.xml' file, the format of which is
decently documented. So you can take your template and just build on
top of it.

This is much nicer than generating RTF by hand, which I also do in the
same program :)

This guy provides automated conversion online using a similar system:

 http://oooconv.free.fr/engine/OOOconv.php



-- 
===============================================================
<erwin at andreasen.org>                           Herlev, Denmark     
<URL:http://www.andreasen.org/>                             <*>   
===============================================================





More information about the Python-list mailing list