dia2pdf - high quality pdf figures with dia and pdflatex

by Martin Monperrus

Dia is a wonderful tool to create figures.
Latex (and especially pdflatex) is a wonderful tool to create high quality documents.
But how to use dia figures in latex documents?

Exporting to PNG of JPG produces low quality figures. Exporting to EPS is OK, but using EPS figures with pdflatex is difficult.

The solution is to export to EPS, and to transform to PDF (with a tricky option). Contrary to PNG or JPG, you obtain vector graphics!

$ dia -e TMPFILE -t eps myfigure.dia # this can be done using the Export widget in dia as well
$ ps2pdf -dEPSCrop TMPFILE myfigure.pdf

Then, a dia2pdf script can be:
#!/bin/bash
## the filename without the extension .dia
ROOT=${1:0:${#1}-4}

TMPFILE=$(tempfile)
dia -e $TMPFILE -t eps $1

ps2pdf -dEPSCrop $TMPFILE $ROOT.pdf
Tagged as: