How to create scalable eps-graphics from dot and OpenOffice files

16.February 2005 - 13:22

In my diploma thesis i worked with two kinds of images. First, i created descriptions of hierarchies of entities in the dot language and use dot from the GraphViz package to visualize them. Second, i created standard slides with OpenOffice.

This is a story of how to produce good scalable encapsulated postscript images to use them in latex and pdflatex.

A “good” eps-image is an eps-image that complies with these requirements:

  1. The file is an eps-file and not a ps-file.
  2. There is a bounding box defined.
  3. The bounding box is minimal to the content (no margins)
  4. There is no tiff- or whatever-preview bitmap saved inside the eps-file.

dot output

dot can create postscript files with the parameter -Tps, e.g.:
dot -Tps -o output.ps input.dot
The output-file has a defined minimal bounding box and there is no preview. The only problem: It is not an eps-file, so that the bounding box will be ignored from pdflatex and the image has the measurements of a sheet of paper.

There is a script from Ghostscript to convert ps to eps (ps2epsi), but that script relocates or changes the perfect minimal bounding box from dot to a wrong one and also creates a preview.

There is a simple solution to thar problem: Change the first line of the postscript from PS-Adobe-2.0 to PS-Adobe-2.0 EPSF-1.2 and everything is fine, because now latex uses the bounding box.

I have created a little shell script, which starts dot in ps mode an creates an eps- and a pdf-file from the dot postscript output

OpenOffice slides

I have used slides to create pictures which cannot be created by dot. OpenOffice can export slides in eps. The eps-export does work but you have to use the latest OpenOffice version. In version 1.1rc2 there is a bug in the export-filter for eps which produces ill-favored letters if you stretch a tile with letters in it. In Version 1.1.4rc the problem is solved.

But one difficulty appears. OpenOffice creates an eps-image of the whole page, so you have to create a page-format which fits your image:

  • Select everything you want to export.
  • Read off the width and height of this collection from the status line.
  • Move the selection to the upper-left corner of the page.
  • Change the page dimensions (do not klick the checkbox “fit object to paper format”).

Afterwards you may export an eps-file without a preview (you must not klick the corresponding checkbox in the export window) and a minimal bounding box.

That’s the end of it.

One Response to “How to create scalable eps-graphics from dot and OpenOffice files”

You can follow any responses to this entry through the RSS 2.0 feed.

  1. a gravatar From Martin Görg:

    Haha,
    du bist mein Held Sebastian. Der Trick mit dem Ändern der ersten Zeile der ps-Datei hat mir echt ne menge Arbeit erspart. Ich wollte mich grad über Graphviz, dot(ty) usw. ärgern. Jetzt kann ich aber wunderbar die ps-Datei in LyX einfügen und weiterhin bequem mit pdflatex arbeiten.

    Dickes Danke und Gruß
    Martin

Comment this entry

Wanna have an icon? Create your Gravatar!