Interface to the Ghostscript C-API, both high- and low-level, based on ctypes
Ghostscript, is a well known interpreter for the PostScript language and for PDF. This package implements a interface to the Ghostscript C-API using ctypes. Both a low-level and a pythonic, high-level interface are provided.
This package is currently tested only under GNU/Linux. Please report whether it works in your environment, too. Thanks.
Here is an example for how to use the high-level interface of
python-ghostscript. This implements a very basic ps2pdf-tool:
import sys import ghostscript args = [ "ps2pdf", # actual value doesn't matter "-dNOPAUSE", "-dBATCH", "-dSAFER", "-sDEVICE=pdfwrite", "-sOutputFile=" + sys.argv, "-c", ".setpdfwrite", "-f", sys.argv ] ghostscript.Ghostscript(*args)
Here an example for passing a string document to Ghostscript:
doc = """%! /Helvetica findfont 20 scalefont setfont 50 50 moveto (Hello World) show showpage """ import ghostscript args = """test.py -dNOPAUSE -dBATCH -dSAFER -sDEVICE=pdfwrite -sOutputFile=/tmp/out.pdf -c .setpdfwrite""".split() GS = ghostscript.Ghostscript(*args) try: GS.run_string(doc) finally: GS.exit()
More examples can be found in the
examples subdirectory of the
|Please note:||This package is meant for developers. Even if there are some usable examples included, installations instructions are meant for developers.|
ctypesis already included in Python 2.5 and higher)
Since this package is meant for developers, we assume you have experience in installing Python packages.
python-ghostscript is listed on PyPI (Python Package Index), so
you can install it using
pip as usual. Please
refer to the manuals of
pip for further
Alternatively you may download and unpack the source package of
python-ghostscript from http://pypi.python.org/pypi/ghostscript and
python ./setup.py install
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
|File Name & Checksum SHA256 Checksum Help||Version||File Type||Upload Date|
|ghostscript-0.4.1.tar.bz2 (28.1 kB) Copy SHA256 Checksum SHA256||–||Source||Feb 9, 2011|
|ghostscript-0.4.1.zip (46.2 kB) Copy SHA256 Checksum SHA256||–||Source||Feb 9, 2011|