2 # -*- coding: ISO-8859-1 -*-
5 # Copyright (C) 2003 Jörg Lehmann <joergl@users.sourceforge.net>
7 # epstopng is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2 of the License, or
10 # (at your option) any later version.
12 # epstopng is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with epstopng; if not, write to the Free Software
19 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 # TODO: - set dpi in png (don't know how to do this in PIL)
22 # - this is much too slow --- consider a rewrite in C
26 from pyx
import dvifile
, canvas
, trafo
, unit
29 progname
= "dvips v0.1: dvi to ps converter based on PyX"
32 def dvips(dviname
, psname
, vshift
="-1 t cm"):
33 fontmap
= dvifile
.readfontmap(["psfonts.map"])
34 df
= dvifile
.dvifile(dviname
, fontmap
=fontmap
)
43 p
= canvas
.page(paperformat
="a4")
44 p
.insert(c
, [trafo
.translate(0, unit
.length(vshift
)+p
.bbox().height())])
51 print "Copyright (C) 2004 Jörg Lehmann <joergl@users.sourceforge.net>"
52 print "usage: dvips [options] <eps-file>"
53 print "-h, --help: show this help"
54 print "-o, --output <file>: output file name (optional)"
59 opts
, args
= getopt
.getopt(sys
.argv
[1:], "ho:", ["help", "output"])
60 except getopt
.GetoptError
:
61 # print help information and exit:
66 if o
in ("-h", "--help"):
69 if o
in ("-o", "--output"):
74 raise RuntimeError("can't handle several input files")
76 raise RuntimeError("must specify an input file (reading from stdin is not yet supported)")
77 if not input.endswith(".dvi"):
78 input = input + ".dvi"
80 output
= input[:-4] + ".ps"
83 def profilefunction(f
):
84 import hotshot
, hotshot
.stats
85 prof
= hotshot
.Profile("test.prof")
88 stats
= hotshot
.stats
.load("test.prof")
90 stats
.sort_stats('time', 'calls')
93 if __name__
== "__main__":
95 # profilefunction(main)