mardi 27 octobre 2009

Makefile to convert openoffice odg files to pdf

This makefile allows converting from OpenOffice odg files to pdf files.
It requires unoconv, ps2eps and poppler-utils.

Why doing all this mess ?
Unoconv converts from odg to pdf however the resulting pdf do not fit the drawing. So this Makefile pass through a lot of format to remove all the blank around the drawing.

------------------------------------------------------------------------------

# Makefile to transform each odg file to pdf file, the size of the pdf fit with the drawing
#
# Operations :
# 1) odg -> pdft (pdf with a lot of blank around the drawing)
# 2) pdft -> ps
# 3) ps -> eps
# 4) eps -> pdf
#
# Troubleshoot : unoconv sometimes crashes when a lot of odg file are present, to avoid this
# crash call first "make pdft", then "make pdf"

ODG= $(wildcard *.odg)

PDFT= $(ODG:.odg=.pdft)
PS= $(PDFT:.pdft=.ps)
EPS= $(PS:.ps=.eps)
PDF= $(EPS:.eps=.pdf)

pdft:$(PDFT)
ps:$(PS)
eps:$(EPS)
pdf:$(PDF)

all: pdf

%.pdft: %.odg
unoconv --stdout --doctype=graphics $< > $@

%.ps: %.pdft
pdftops $< $@

%.eps: %.ps
ps2eps -f -l $<

%.pdf: %.eps
epstopdf $<

clean:
rm -f *.eps *.ps *.pdft

dist-clean:distclean

distclean: clean
rm -f *.pdf

1 commentaire:

  1. Hello,

    I'm trying to use your script to convert odg file to pdf, but when i ran it, I got this error :
    ~# make all
    makefile:30: *** missing separator. Stop.

    I'm using ubuntu 10.4 x86.

    Thanks,

    Guillaume

    RépondreSupprimer