Calling Ghostscript from Python

Georg Bisseling Georg.Bisseling at pallas.com
Fri Nov 9 09:22:38 EST 2001


Kerstin wrote:
> 
> Hi,
> 
> I'm trying to call the ghostscript to convert some PS to PDF. I'm
> working on Win95, so the os.system() always returns '0'.
> When the cmd is running, the DOS-Box opens and I get the error message
> "File or directory not found".
> I also checked if the PS are readable; and when I change the cmd to
> something else (like "md new_dir") it works.
> 
> ghost_dir = 'c:\ghost\gs\gs7.00\lib'
> cmd = ghost_dir + '\ps2pdf13.bat ' + ps_file + ' ' + pdf_file
> os.system(cmd)
> 
> I think there must be something wrong with the pathname or rather the
> ghost environment. How can I check this?
> I'm using full pathnames for 'ps_file' and 'pdf_file' too! Might this
> cause problems?
> 
> Can anybody help me?
> Thanx,
> Kerstin

ghost_dir = 'c:\\ghost\\gs\\gs7.00\\lib'
cmd = ghost_dir + '\\ps2pdf13.bat ' + ps_file + ' ' + pdf_file

should do the trick.

You should use os.path.join to join pathnames platform independent.



More information about the Python-list mailing list