When you check out the svn, please try to apply the patch attached. patch -p1 < ps_distiller.patch
I hope this solves your problem. Regards, -JJ On Mon, Jan 11, 2010 at 7:25 PM, Jae-Joon Lee <lee.j.j...@gmail.com> wrote: > On Mon, Jan 11, 2010 at 6:49 PM, John Reid <j.r...@mail.cryst.bbk.ac.uk> > wrote: >> Thanks for help so far. Any more ideas? I'll try the svn if it is just a >> case of checking it out and compiling. >> > > Please try. > I don't think the current svn version will make any difference. But, > at least I can send you a patch that I think fix the problem so that > you can test it. > I'll post the patch here soon. > > Regards. > > -JJ >
diff --git a/lib/matplotlib/backends/backend_ps.py b/lib/matplotlib/backends/backend_ps.py index a1366b3..9e0636a 100644 --- a/lib/matplotlib/backends/backend_ps.py +++ b/lib/matplotlib/backends/backend_ps.py @@ -1383,14 +1383,17 @@ def gs_distill(tmpfile, eps=False, ptype='letter', bbox=None): This yields smaller files without illegal encapsulated postscript operators. The output is low-level, converting text to outlines. """ - paper = '-sPAPERSIZE=%s'% ptype + + paper_option = "-sPAPERSIZE=%s" % ptype + psfile = tmpfile + '.ps' outfile = tmpfile + '.output' dpi = rcParams['ps.distiller.res'] if sys.platform == 'win32': gs_exe = 'gswin32c' else: gs_exe = 'gs' + command = '%s -dBATCH -dNOPAUSE -r%d -sDEVICE=pswrite %s -sOutputFile="%s" \ - "%s" > "%s"'% (gs_exe, dpi, paper, psfile, tmpfile, outfile) + "%s" > "%s"'% (gs_exe, dpi, paper_option, psfile, tmpfile, outfile) verbose.report(command, 'debug') exit_status = os.system(command) fh = file(outfile) @@ -1404,11 +1407,11 @@ your image.\nHere is the full report generated by ghostscript:\n\n' + fh.read()) - # Since the the paper size is set to the figure size for eps - # output (in '_print_figure_tex'), pstoeps call is not required. + # The above gs run seem to modify the bbox of the original eps file. + # Thus, it seems that we need to restore the original bbox. - #if eps: - # pstoeps(tmpfile, bbox) + if eps: + pstoeps(tmpfile, bbox, use_original_bbox=True) def xpdf_distill(tmpfile, eps=False, ptype='letter', bbox=None): @@ -1421,9 +1424,13 @@ def xpdf_distill(tmpfile, eps=False, ptype='letter', bbox=None): pdffile = tmpfile + '.pdf' psfile = tmpfile + '.ps' outfile = tmpfile + '.output' + + if eps: paper_option = "-dEPSCrop" + else: paper_option = "-sPAPERSIZE=%s" % ptype + command = 'ps2pdf -dAutoFilterColorImages=false \ --sColorImageFilter=FlateEncode -sPAPERSIZE=%s "%s" "%s" > "%s"'% \ -(ptype, tmpfile, pdffile, outfile) +-sColorImageFilter=FlateEncode %s "%s" "%s" > "%s"'% \ +(paper_option, tmpfile, pdffile, outfile) if sys.platform == 'win32': command = command.replace('=', '#') verbose.report(command, 'debug') exit_status = os.system(command) @@ -1446,16 +1453,24 @@ image.\nHere is the full report generated by pdftops: \n\n' + fh.read()) os.remove(tmpfile) shutil.move(psfile, tmpfile) if eps: - pstoeps(tmpfile, bbox) + pstoeps(tmpfile, bbox, use_original_bbox=True) for fname in glob.glob(tmpfile+'.*'): os.remove(fname) -def get_bbox(tmpfile, bbox): +def get_bbox(tmpfile, bbox, use_original_bbox=False): """ Use ghostscript's bbox device to find the center of the bounding box. Return an appropriately sized bbox centered around that point. A bit of a hack. """ + + if use_original_bbox: + l, b, r, t = bbox + bbox_info = '%%%%BoundingBox: %d %d %d %d' % (l, b, npy.ceil(r), npy.ceil(t)) + hires_bbox_info = '%%%%HiResBoundingBox: %.6f %.6f %.6f %.6f' % (l, b, r, t) + + return '\n'.join([bbox_info, hires_bbox_info]) + outfile = tmpfile + '.output' if sys.platform == 'win32': gs_exe = 'gswin32c' else: gs_exe = 'gs' @@ -1493,11 +1508,11 @@ Here is the Ghostscript output:\n\n%s'% bbox_info) return '\n'.join([bbox_info, hires_bbox_info]) -def pstoeps(tmpfile, bbox): +def pstoeps(tmpfile, bbox, use_original_bbox=False): """ Convert the postscript to encapsulated postscript. """ - bbox_info = get_bbox(tmpfile, bbox) + bbox_info = get_bbox(tmpfile, bbox, use_original_bbox=use_original_bbox) epsfile = tmpfile + '.eps' epsh = file(epsfile, 'w') @@ -1552,6 +1567,7 @@ def pstoeps(tmpfile, bbox): shutil.move(epsfile, tmpfile) + class FigureManagerPS(FigureManagerBase): pass
------------------------------------------------------------------------------ This SF.Net email is sponsored by the Verizon Developer Community Take advantage of Verizon's best-in-class app development support A streamlined, 14 day to market process makes app distribution fast and easy Join now and get one step closer to millions of Verizon customers http://p.sf.net/sfu/verizon-dev2dev
_______________________________________________ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users