~openerp-groupes/openobject-server/6.0-fix-setup-windows

« back to all changes in this revision

Viewing changes to bin/reportlab/tools/py2pdf/idle_print.py

  • Committer: pinky
  • Date: 2006-12-07 13:41:40 UTC
  • Revision ID: pinky-3f10ee12cea3c4c75cef44ab04ad33ef47432907
New trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#Copyright ReportLab Europe Ltd. 2000-2004
 
2
#see license.txt for license details
 
3
#history http://www.reportlab.co.uk/cgi-bin/viewcvs.cgi/public/reportlab/trunk/reportlab/tools/py2pdf/idle_print.py
 
4
 
 
5
# idle_print [py2pdf_options] filename
 
6
__version__=''' $Id$ '''
 
7
# you should adjust the globals below to configure for your system
 
8
 
 
9
import sys, os, py2pdf, string, time
 
10
#whether we remove input/output files; if you get trouble on windows try setting _out to 0
 
11
auto_rm_in  = 1
 
12
auto_rm_out = 1
 
13
viewOnly = 0
 
14
 
 
15
#how to call up your acrobat reader
 
16
if sys.platform=='win32':
 
17
    acrord = 'C:\\Program Files\\Adobe\\Acrobat 4.0\\Reader\\AcroRd32.exe'
 
18
    def printpdf(pdfname):
 
19
        args = [acrord, pdfname]
 
20
        os.spawnv(os.P_WAIT, args[0], args)
 
21
else:
 
22
    acrord = 'acroread'
 
23
    def printpdf(pdfname):
 
24
        if viewOnly:
 
25
            cmd = "%s %s" % (acrord,pdfname)
 
26
        else:
 
27
            cmd = "%s -toPostScript < %s | lpr" % (acrord,pdfname)
 
28
        os.system(cmd)
 
29
 
 
30
args = ['--input=python']
 
31
files = []
 
32
for f in sys.argv[1:]:
 
33
    if f[:2]=='--':
 
34
        opt = f[2:]
 
35
        if opt =='no_auto_rm_in':
 
36
            auto_rm_in = 0
 
37
        elif opt =='auto_rm_in':
 
38
            auto_rm_in = 1
 
39
        elif opt =='no_auto_rm_out':
 
40
            auto_rm_out = 0
 
41
        elif opt =='auto_rm_out':
 
42
            auto_rm_out = 1
 
43
        elif opt =='viewonly':
 
44
            viewOnly = 1
 
45
        elif opt[:9] =='acroread=':
 
46
            acrord = opt[9:]
 
47
        else:
 
48
            args.append(f)
 
49
    else: files.append(f)
 
50
 
 
51
for f in files:
 
52
    py2pdf.main(args+[f])
 
53
    if auto_rm_in: os.remove(f)
 
54
    pdfname = os.path.splitext(f)[0]+'.pdf'
 
55
    printpdf(pdfname)
 
56
    if auto_rm_out: os.remove(pdfname)
 
 
b'\\ No newline at end of file'