dabo Commit
Revision 7195
Date: 2012-06-08 13:25:16 -0700 (Fri, 08 Jun 2012)
Author: Paul
Trac: http://trac.dabodev.com/changeset/7195

Changed:
U   trunk/dabo/lib/reportUtils.py

Log:
Added printerPort and copies arguments to reportUtils.printReport().


Diff:
Modified: trunk/dabo/lib/reportUtils.py
===================================================================
--- trunk/dabo/lib/reportUtils.py       2012-06-06 20:02:33 UTC (rev 7194)
+++ trunk/dabo/lib/reportUtils.py       2012-06-08 20:25:16 UTC (rev 7195)
@@ -75,28 +75,34 @@
                                        subprocess.Popen((viewer, path))
 
 
-def printPDF(path, printerName=None):
+def printPDF(path, printerName=None, printerPort=None, copies=1):
        """Print the passed PDF file to the default printer.
 
-       If gsprint is installed and on the path, the printerName parameter
-       can be used to specify which printer to output to. NOTE: gsprint
-       is part of gsview, and gsview depends on ghostscript. These packages
-       are GPL - to avoid legal issues make sure your end user installs them
-       separately from your application.
+       If gsprint is installed and on the path:
+               1) printerName specifies which printer to output to. 
+               2) printerPort specifies which port to output to.
+               3) multiple copies are handled more efficiently.
+
+       NOTE: gsprint   is part of gsview, and gsview depends on ghostscript.
+       These packages are GPL - to avoid legal issues make sure your end 
+       user installs themseparately from your application.
        """
        if gsprint:
                args = ["gsprint", path]
                if printerName:
                        args.insert(-1, '-printer')
                        args.insert(-1, "%s" % printerName)
+               if copies > 1:
+                       args.insert(-1, '-copies')
+                       args.insert(-1, str(copies))
                p = subprocess.Popen(args, stderr=subprocess.PIPE, 
stdout=subprocess.PIPE)
                p.communicate()
        else:
-               try:
-                       os.startfile(path, "print")
-               except AttributeError:
-                       # startfile() only available on Windows
-                       subprocess.Popen(("lpr", path))
+               for i in range(copies):
+                       if sys.platform.startswith("win"):
+                               os.startfile(path, "print")
+                       else:
+                               subprocess.Popen(("lpr", path))
 
 
 def getTestCursorXmlFromDataSet(dataset):



_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-dev
Searchable Archives: http://leafe.com/archives/search/dabo-dev
This message: 
http://leafe.com/archives/byMID/[email protected]

Reply via email to