~ubuntu-branches/ubuntu/trusty/pyx/trusty

« back to all changes in this revision

Viewing changes to contrib/dviconvert.py

  • Committer: Bazaar Package Importer
  • Author(s): Thomas Viehmann
  • Date: 2006-11-26 14:04:53 UTC
  • mfrom: (2.1.3 edgy)
  • Revision ID: james.westby@ubuntu.com-20061126140453-1dq3cycpspmlik2t
Tags: 0.9-3
* New maintainer. Thank you for more than three years of
  maintenance,  Graham! Closes: #400087
* Don't hard-code python 2.3 in manual/Makefile.
  Thanks to Matthias Klose for the bug report and patch.
  Closes: #392634
* Remove obsolete dh_python call from debian/rules.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env python
 
2
# -*- coding: ISO-8859-1 -*-
 
3
#
 
4
#
 
5
# Copyright (C) 2005 Andr� Wobst <wobsta@users.sourceforge.net>
 
6
#
 
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.
 
11
#
 
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.
 
16
#
 
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
 
20
 
 
21
from optparse import OptionParser
 
22
from pyx import *
 
23
from pyx import bbox, dvifile, version
 
24
 
 
25
parser = OptionParser(usage="usage: %prog [-b] [-p paperformat] -o output-file dvi-file",
 
26
                      version="%prog " + version.version)
 
27
parser.add_option("-o", "--output",
 
28
                  type="string", dest="output",
 
29
                  help="output-file")
 
30
parser.add_option("-p", "--paperformat",
 
31
                  type="string", dest="paperformat", default=None,
 
32
                  help="optional paper format string")
 
33
parser.add_option("-b", "--writebbox",
 
34
                  action="store_true", dest="writebbox", default=0,
 
35
                  help="Add bouding box information on PS and PDF when a paperformat is defined")
 
36
(options, args) = parser.parse_args()
 
37
if len(args) != 1:
 
38
    parser.error("can process a single dvi-file only")
 
39
 
 
40
if options.paperformat:
 
41
    options.paperformat = getattr(document.paperformat, options.paperformat)
 
42
df = dvifile.dvifile(args[0], dvifile.readfontmap(["psfonts.map"]))
 
43
d = document.document()
 
44
while 1:
 
45
    dvipage = df.readpage()
 
46
    if not dvipage:
 
47
        break
 
48
    if options.paperformat:
 
49
        aligntrafo = trafo.translate(-unit.t_inch, unit.t_inch + paperformat.height)
 
50
        aligneddvipage = canvas.canvas([aligntrafo])
 
51
        aligneddvipage.insert(dvipage)
 
52
        p = document.page(aligneddvipage, paperformat=paperformat)
 
53
    else:
 
54
        p = document.page(dvipage)
 
55
    d.append(p)
 
56
if options.writebbox:
 
57
    d.writetofile(options.output)
 
58
else:
 
59
    d.writetofile(options.output, writebbox=1)