@@ -1546,26 +1546,16 @@ def xpdf_distill(tmpfile, eps=False, ptype='letter', bbox=None, rotated=False):
15461546 pdffile = tmpfile + '.pdf'
15471547 psfile = tmpfile + '.ps'
15481548
1549- if eps :
1550- paper_option = "-dEPSCrop"
1551- else :
1552- if sys .platform == "win32" :
1553- paper_option = "-sPAPERSIZE#%s" % ptype
1554- else :
1555- paper_option = "-sPAPERSIZE=%s" % ptype
1556-
1557- if sys .platform == "win32" :
1558- command = [str ("ps2pdf" ), "-dAutoFilterColorImages#false" ,
1559- "-dAutoFilterGrayImages#false" ,
1560- "-sGrayImageFilter#FlateEncode" ,
1561- "-sColorImageFilter#FlateEncode" , paper_option , tmpfile ,
1562- pdffile ]
1563- else :
1564- command = [str ("ps2pdf" ), "-dAutoFilterColorImages=false" ,
1565- "-dAutoFilterGrayImages=false" ,
1566- "-sGrayImageFilter=FlateEncode" ,
1567- "-sColorImageFilter=FlateEncode" , paper_option , tmpfile ,
1568- pdffile ]
1549+ # Pass options as `-foo#bar` instead of `-foo=bar` to keep Windows happy
1550+ # (https://www.ghostscript.com/doc/9.22/Use.htm#MS_Windows).
1551+ command = [str ("ps2pdf" ),
1552+ "-dAutoFilterColorImages#false" ,
1553+ "-dAutoFilterGrayImages#false" ,
1554+ "-dAutoRotatePages#false" ,
1555+ "-sGrayImageFilter#FlateEncode" ,
1556+ "-sColorImageFilter#FlateEncode" ,
1557+ "-dEPSCrop" if eps else "-sPAPERSIZE#%s" % ptype ,
1558+ tmpfile , pdffile ]
15691559 _log .debug (command )
15701560
15711561 try :
@@ -1624,7 +1614,7 @@ def get_bbox(tmpfile, bbox):
16241614 """
16251615
16261616 gs_exe = ps_backend_helper .gs_exe
1627- command = [gs_exe , "-dBATCH" , "-dNOPAUSE" , "-sDEVICE=bbox" "%s" % tmpfile ]
1617+ command = [gs_exe , "-dBATCH" , "-dNOPAUSE" , "-sDEVICE=bbox" , "%s" % tmpfile ]
16281618 _log .debug (command )
16291619 p = subprocess .Popen (command , stdin = subprocess .PIPE ,
16301620 stdout = subprocess .PIPE , stderr = subprocess .PIPE ,
0 commit comments