/ LibreOffice Tips & Tricks

by levien on za 23 april 2011 // Posted in misc // under

Installing LibreOffice on Ubuntu 10.04 LTS (Lucid Lynx)

LibreOffice was forked from after Ocracle acquired Sun and started charging money for previously free products (such as the ODF import filter for Microsoft Office). The 3.3 release of LibreOffice has a number of interesting features (such as SVG import/export and better support for RTF end MS Office), and newer Ubuntu versions ship with LibreOffice rather than To install LibreOffice in Ubuntu Lucid, add the LibreOffice PPA to your Software Sources and install libreoffice, libreoffice-gnome and libreoffice-pdfimport. If you run into problems, try manually removing all vestiges of first: sudo apt-get purge "openoffice*"

Using Vector Graphics in files

UPDATE: LibreOffice supports SVG import and PDF import since the 3.3 release.

Using vector graphic formats other than Draw in Writer and Impress documents remains a major headache. One wonders why an XML-based Office application that is so keen on ISO standards and PDF export still doesn’t have proper support for including SVG and PDF images. An import function for PostScript files is provided, but unfortunately only works on PostScript printers. When exporting to PDF, the preview-bitmap is used instead, which can lead to unpleasant surprises…

Currently, the easiest way of importing vector graphics is to first render them as PNG bitmaps, using a program such as Inkscape (for SVG and PDF) or GhostScript (for PostScript and PDF). Of course this somewhat defeats the purpose of having vector graphics in the first place. It’s still the best choice for presentations though, as OpenOffice .org has no antialiasing for vector graphics at the moment.

You can also convert SVG to PNG on the commandline, using something like:

inkscape -z --file=original.svg --export-png=converted.png --export-area-drawing --export-dpi=200

In order to convert an entire batch of SVG files into PNG just do:

for infile in *.svg ; do outfile=${infile//svg/png} ; inkscape -z --file=$infile --export-png=$outfile ; done

Optionally you can add flags such as --export-area-drawing, --export-dpi=300 or -w600 -h400. See the Inkscape manpage for more details.

There are cases where you really want to use vector graphics (e.g. for high-quality printing of line drawings, graphs, etc.). Luckily, almast all vector graphics formats can easily be converted to PDF, and PDF import is supported as of 3.0. It does require you to install the Sun PDF Import Extension. In Ubuntu, this extension is conveniently provided as a package ( I did some testing, and it works well on simple PDF files. More complex graphics can get messed up though, and the spacing of text is sometimes a bit odd. But the extension is still beta, and so will probably improve over time. Currently this looks like the best way to import vector graphics into OpenOffice, especially when combined with Inkscape’s excellent PDF import/export features.

You can convert SVG to PDF on the commandline using something like:

inkscape -z --file=original.svg --export-pdf=converted.pdf

This can be useful, e.g. to convert a batch of SVG files into PDF just do:

for infile in *.svg ; do outfile=${infile//svg/pdf} ; inkscape -z --file=$infile --export-pdf=$outfile ; done

Native support for an SVG import filter is also being worked on, and until then it is possible to use the SVG Import extension.

Unfortunately, attempting to open an Inkscape SVG file with the SVG Import Extension will often generate a “General Input/Output Error” in This is caused by the fact that the extension doesn’t support the way Inkscape includes text in SVG files (textPath). You can circumvent this by either converting all text objects in your Inkscape drawing to paths (Object->Object to path) or by “unflowing” them using Text->Unflow (which will keep your text editable, but may or may not cause strange side-effects, like sudden changes in character size).

Another way to include vector graphics in files is to convert them to a Windows Metafile (WMF or EMF). Several tools are available for this (such as uniconverter and pstoedit), although none seem able to do an exact conversion. Inkscape and pstoedit can also write StarOffice/ Draw files directly, albeit again with loss of some picture elements (like text).

To summarise, if you want to include vector graphics in documents, it’s usually best to convert them either to PDF or alternatively to PNG (for complex vector drawings with lots of gradients, or for use of graphics in presentations). PDF can be imported into 3.x using the Sun PDF Import Extension. Conversion of SVG-files to PDF, or SVG/PDF to PNG is best done using InkScape. PostScript (PS or EPS) can easily be converted to PDF in Ubuntu, using pstopdf (from the ghostscript package) or epstopdf (from the texline-extra-utils package). PostScript can be converted to PNG using ImageMagic’s all-powerful convert command.

As a final note, the above advice for conversion to PDF/PNG is of course also very useful if you’re working with PDFLaTeX!

Using OpenType fonts in under Linux

It looks like OpenType fonts will finally be supported in 3.2. The status of this feature is tracked as otf01 in the Sun EIS and [Issue #43029 in OOo QA][].

Advanced page numbers in

Beware, here be monsters. ;-) However, OOo guru Solveig Haugland has written a useful guide for the common case where you want some pages to have numbers, and others not (e.g. title pages).

UPDATE: LibreOffice now has a new dialog-box for creating and managing title pages, which also allows some control over page-numbering.

Batch conversion of office documents

Imagine you need to convert a lot of office documents, e.g. from MS Office to ODF (MS Word .doc to ODT, Powerpoint .ppt to ODP, or Excel .xls to ODS), or vice versa, or any of these formats to PDF or HTML. Doing this by hand is going to take ages. Luckily there’s a way to do it automagically from the shell, using a little tool called unoconv (to install in Ubuntu: sudo apt-get install unoconv). Conversion (e.g. ODT documents to PDF) is as simple as running: unoconv -b pdf *.odt. See the README file for more details.

A somewhat more lightweight way to batch-convert documents is to use AbiWord (Ubuntu: sudo apt-get install abiword abiword-plugins). For instance, to convert a set of MS Word file to PDF: abiword --to=pdf *.doc (see man abiword for more details).

Documents consisting of multiple files

Often it is practical to split a document into multiple files, for instance

if a document is large or is being written by multiple authors. Of course it’s not very practical if you need to paste all the parts together every time you want to print or distribute the entire document.

To make life easier, OpenOffice Writer supports Master Documents. These useful beasties will automagically import and integrate subdocuments for printing and PDF creation. Take a look at this guide to see how it’s done. Although it’ll cost you around half an our to set up a Master Document the first time, it may save you tons of time in combining and updating subdocuments later on…

Installing OpenOffice 3 on older Ubuntu versions (e.g. 8.10) 3 ships with Ubuntu 9.04 and later, but it was not yet in 8.10. To install it anyway on 8.10, see: The OOo 3.0 Personal Package Archive. Add this to your repositories and update (or install the meta-package if you haven’t got it yet). Don’t forget to install the Sun PDF Import extension as well. It is conveniently provided as a package (