gdt: Kangaroo road sign (Default)
Glen Turner ([personal profile] gdt) wrote2008-04-14 03:48 pm
Entry tags:

Convert DIA diagrams to PDF

Dia cannot export directly to Adobe's Portable Document Format. It can export to the Encapsulated PostScript vector format. As EPS is an Adobe specification it shares a lot of concepts with PDF, giving a pleasing accuracy in the PDF file.

The utility which does the magic is epstopdf, which is part of the TeTeX TeX distribution. This Perl script sets the bounding box and calls GhostScript to do the heavy lifting of the conversion.

Here is a GNU Make file for batch conversion of Dia diagrams in the current directory to PDF. It's a nice skeleton for people who have long-running batched file tasks, as Make takes care of a lot of details which are a real pain in shell scripts (such cleaning up after a Ctrl-C).

#!/usr/bin/gmake -f

DIA=dia
DIAFLAGS=--log-to-stderr --nosplash
EPSTOPDF=epstopdf
EPSTOPDFFLAGS=

%.eps : %.dia
        $(DIA) $(DIAFLAGS) --filter=eps --export=$@ $<

%.pdf : %.eps
        $(EPSTOPDF) $(EPSTOPDFFLAGS) --outfile=$@ $<

SRC=$(wildcard *.dia)
DST=$(SRC:.dia=.pdf)

all: $(DST)

.PHONY: clean
clean:
        $(RM) $(RMFLAGS) $(DST)
        $(RM) $(RMFLAGS) $(SRC:.dia=.eps)

For the record, this is on Fedora 8:

$ rpm --query --file `which epstopdf`
tetex-3.0-44.8.fc8
$ rpm --query --file `which dia`
dia-0.96.1-6.fc8

Post a comment in response:

This account has disabled anonymous posting.
(will be screened)
(will be screened)
If you don't have an account you can create one now.
HTML doesn't work in the subject.
More info about formatting

If you are unable to use this captcha for any reason, please contact us by email at support@dreamwidth.org