[GRASS-SVN] r56082 - grass/trunk/gui/wxpython/psmap
svn_grass at osgeo.org
svn_grass at osgeo.org
Thu May 2 09:45:12 PDT 2013
Author: annakrat
Date: 2013-05-02 09:45:12 -0700 (Thu, 02 May 2013)
New Revision: 56082
Modified:
grass/trunk/gui/wxpython/psmap/frame.py
Log:
wxGUI/composer: fix generating PDF on Windows
Modified: grass/trunk/gui/wxpython/psmap/frame.py
===================================================================
--- grass/trunk/gui/wxpython/psmap/frame.py 2013-05-02 14:32:52 UTC (rev 56081)
+++ grass/trunk/gui/wxpython/psmap/frame.py 2013-05-02 16:45:12 UTC (rev 56082)
@@ -220,15 +220,16 @@
def OnPDFFile(self, event):
"""!Generate PDF from PS with ps2pdf if available"""
- try:
- p = grass.Popen(["ps2pdf"], stderr = grass.PIPE)
- p.stderr.close()
+ if not sys.platform == 'win32':
+ try:
+ p = grass.Popen(["ps2pdf"], stderr = grass.PIPE)
+ p.stderr.close()
+
+ except OSError:
+ GMessage(parent = self,
+ message = _("Program ps2pdf is not available. Please install it first to create PDF."))
+ return
- except OSError:
- GMessage(parent = self,
- message = _("Program ps2pdf is not available. Please install it first to create PDF."))
- return
-
filename = self.getFile(wildcard = "PDF (*.pdf)|*.pdf")
if filename:
self.PSFile(filename, pdf = True)
@@ -292,14 +293,30 @@
return
if event.userData['pdfname']:
+ if sys.platform == 'win32':
+ command = ['gswin32c',
+ '-P-', '-dSAFER',
+ '-dCompatibilityLevel=1.4',
+ '-q', '-P-',
+ '-dNOPAUSE', '-dBATCH',
+ '-sDEVICE=pdfwrite',
+ '-dPDFSETTINGS=/prepress', '-r1200',
+ '-sstdout=%stderr',
+ '-sOutputFile=%s' % event.userData['pdfname'],
+ '-P-', '-dSAFER',
+ '-dCompatibilityLevel=1.4',
+ '-c', '.setpdfwrite', '-f',
+ event.userData['filename']]
+ else:
+ command = ['ps2pdf', '-dPDFSETTINGS=/prepress', '-r1200',
+ event.userData['filename'], event.userData['pdfname']]
try:
- proc = grass.Popen(['ps2pdf', '-dPDFSETTINGS=/prepress', '-r1200',
- event.userData['filename'], event.userData['pdfname']])
-
+ proc = grass.Popen(command)
ret = proc.wait()
if ret > 0:
GMessage(parent = self,
- message = _("ps2pdf exited with return code %s") % ret)
+ message = _("%(prg)s exited with return code %(code)s") % {'prg': command[0],
+ 'code': ret})
else:
self.SetStatusText(_('PDF generated'), 0)
except OSError, e:
More information about the grass-commit
mailing list