Interface to the Ghostscript C-API, both high- and low-level, based on ctypes
Project description
- Version:
- 0.7
- License:
GNU General Public License v3 or later (GPLv3+)
- Homepage:
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.
Example
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 locale import ghostscript args = [ "ps2pdf", # actual value doesn't matter "-dNOPAUSE", "-dBATCH", "-dSAFER", "-sDEVICE=pdfwrite", "-sOutputFile=" + sys.argv[1], "-c", ".setpdfwrite", "-f", sys.argv[2] ] # arguments have to be bytes, encode them encoding = locale.getpreferredencoding() args = [a.encode(encoding) for a in args] ghostscript.Ghostscript(*args)
Here an example for passing a string document to Ghostscript:
doc = b"""%! /Helvetica findfont 20 scalefont setfont 50 50 moveto (Hello World) show showpage quit """ import ghostscript args = b"""test.py -dNOPAUSE -dBATCH -dSAFER -sDEVICE=pdfwrite -sOutputFile=/tmp/out.pdf -c .setpdfwrite""".split() with ghostscript.Ghostscript(*args) as gs: gs.run_string(doc)
More examples can be found in the examples subdirectory of the distribution archive.
Requirements and Installation
- Please note:
This package is meant for developers. Even if there are some usable examples included, installations instructions are meant for developers.
python-ghostscript requires
Python 3.6 or higher (tested with Python 3.6–3.9)
setuptools for installation (see below)
Ghostscript Version 9.0.8 or higher
Installing python-ghostscript
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 install ghostscript as usual. Please refer to the manuals of pip for further information.
Alternatively you my download and unpack the source package of python-ghostscript from http://pypi.python.org/pypi/ghostscript and run:
python ./setup.py install
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file ghostscript-0.7.tar.gz
.
File metadata
- Download URL: ghostscript-0.7.tar.gz
- Upload date:
- Size: 46.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b7875a87098740eb0be3de2d9662d15db727305ca9a6d4b7534a3cc33a4b965a |
|
MD5 | 73946e0695c8a763b48546242237f1a7 |
|
BLAKE2b-256 | 847308197d85f73b09843105c64231b0284965e7fae8ca7ce05c8c2674bbd583 |
File details
Details for the file ghostscript-0.7-py2.py3-none-any.whl
.
File metadata
- Download URL: ghostscript-0.7-py2.py3-none-any.whl
- Upload date:
- Size: 25.3 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 97c70e27ba6b1cab4ab1d9b4cc82d89b8b53e57971f608ded4950b8aa20c78a7 |
|
MD5 | 4d17bbdaf1bd899f1e53945bbe402a08 |
|
BLAKE2b-256 | 895bfa8ac3997ae33d631179ea2e972a5db358d5418b8cccbecfa4dc4c1f3b77 |