HOWTO: Include Code in OpenOffice

This is a simple description on how to include highlighted and formatted code into an OpenOffice document, for example Writer or Impress. I use this approach to include X3D code in an Impress presentation with black background with very good results.

  1. Download an install the utility highlight. This utility is capable of highlighting an extendable long list of languages with configurable colour schemes.
  2. Find your favourite colour scheme for the highlighting. I use black background presentations, so I choose a black background scheme, pablo.
  3. Use highlight to convert your code into RTF format. I use the following command line to give large font and the right colour scheme:highlight -RIs pablo -K 18 -i code.x3d -o file.rtf I have written myself a small script that does this, so I don't have to remember the command line.
  4. The file file.rtf can now be imported into your OpenOffice document and the formating will be included. In Impress select InsertFile...
  5. When I do this, the text block to which the file becomes imported becomes consistently too narrow, rendering line wrapping on some lines. Thus, you may also have to change the block width to make the code fit.