==========================
`python-ghostscript`
==========================
---------------------------------------------------------------------
Python-Interface to the Ghostscript C-API
---------------------------------------------------------------------
:Author: Hartmut Goebel <h.goebel@crazy-compiler.com>
:Version: 0.7
:License: GNU General Public License v3 or later (GPLv3+)
:Homepage: https://gitlab.com/pdftools/python-ghostscript
`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.
__ http://www.ghostscript.com/
__ http://pages.cs.wisc.edu/~ghost/doc/cvs/API.htm
__ http://docs.python.org/library/ctypes.html
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
__ http://www.python.org/download/
__ http://pypi.python.org/pypi/setuptools
__ http://www.ghostscript.com/
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.
__ http://pypi.python.org/pypi
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
.. Emacs config:
Local Variables:
mode: rst
ispell-local-dictionary: "american"
End:
Raw data
{
"_id": null,
"home_page": "https://gitlab.com/pdftools/python-ghostscript",
"name": "ghostscript",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "Ghostscript,PDF,Postscript",
"author": "Hartmut Goebel",
"author_email": "h.goebel@crazy-compilers.com",
"download_url": "https://files.pythonhosted.org/packages/84/73/08197d85f73b09843105c64231b0284965e7fae8ca7ce05c8c2674bbd583/ghostscript-0.7.tar.gz",
"platform": "",
"description": "==========================\n`python-ghostscript`\n==========================\n\n---------------------------------------------------------------------\nPython-Interface to the Ghostscript C-API\n---------------------------------------------------------------------\n\n:Author: Hartmut Goebel <h.goebel@crazy-compiler.com>\n:Version: 0.7\n:License: GNU General Public License v3 or later (GPLv3+)\n:Homepage: https://gitlab.com/pdftools/python-ghostscript\n\n`Ghostscript`__ is a well known interpreter for the PostScript\nlanguage and for PDF. This package implements a interface to the\n`Ghostscript C-API`__ using `ctypes`__. Both a low-level and a pythonic,\nhigh-level interface are provided.\n\n__ http://www.ghostscript.com/\n__ http://pages.cs.wisc.edu/~ghost/doc/cvs/API.htm\n__ http://docs.python.org/library/ctypes.html\n\n\nThis package is currently tested only under GNU/Linux. Please report\nwhether it works in your environment, too. Thanks.\n\n\nExample\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nHere is an example for how to use the high-level interface of\n`python-ghostscript`. This implements a very basic ps2pdf-tool::\n\n import sys\n import locale\n import ghostscript\n\n args = [\n \"ps2pdf\",\t# actual value doesn't matter\n \"-dNOPAUSE\", \"-dBATCH\", \"-dSAFER\",\n \"-sDEVICE=pdfwrite\",\n \"-sOutputFile=\" + sys.argv[1],\n \"-c\", \".setpdfwrite\",\n \"-f\", sys.argv[2]\n ]\n\n # arguments have to be bytes, encode them\n encoding = locale.getpreferredencoding()\n args = [a.encode(encoding) for a in args]\n\n ghostscript.Ghostscript(*args)\n\nHere an example for passing a string document to Ghostscript::\n\n doc = b\"\"\"%!\n /Helvetica findfont 20 scalefont setfont \n 50 50 moveto\n (Hello World) show\n showpage\n quit\n \"\"\"\n\n import ghostscript\n\n args = b\"\"\"test.py\n -dNOPAUSE -dBATCH -dSAFER -sDEVICE=pdfwrite -sOutputFile=/tmp/out.pdf\n -c .setpdfwrite\"\"\".split()\n\n with ghostscript.Ghostscript(*args) as gs:\n gs.run_string(doc)\n\n\nMore examples can be found in the `examples` subdirectory of the\ndistribution archive.\n\n\nRequirements and Installation\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n:Please note: This package is meant for developers. Even if there are\n some usable examples included, installations instructions are meant\n for developers.\n\n`python-ghostscript` requires\n\n* `Python`__ 3.6 or higher (tested with Python 3.6\u20133.9)\n* `setuptools`__ for installation (see below)\n* `Ghostscript`__ Version 9.0.8 or higher\n\n__ http://www.python.org/download/\n__ http://pypi.python.org/pypi/setuptools\n__ http://www.ghostscript.com/\n\n\nInstalling python-ghostscript\n---------------------------------\n\nSince this package is meant for developers, we assume you have\nexperience in installing Python packages.\n\n`python-ghostscript` is listed on `PyPI (Python Package Index)`__, so\nyou can install it using `pip install ghostscript` as usual. Please\nrefer to the manuals of `pip` for further information.\n\n__ http://pypi.python.org/pypi\n\nAlternatively you my download and unpack the source package of\n`python-ghostscript` from http://pypi.python.org/pypi/ghostscript and\nrun::\n\n python ./setup.py install\n\n\n\n.. Emacs config:\n Local Variables:\n mode: rst\n ispell-local-dictionary: \"american\"\n End:\n\n\n",
"bugtrack_url": null,
"license": "GNU General Public License v3 or later (GPLv3+)",
"summary": "Interface to the Ghostscript C-API, both high- and low-level, based on ctypes",
"version": "0.7",
"project_urls": {
"Download": "http://pypi.python.org/pypi/ghostscript",
"Homepage": "https://gitlab.com/pdftools/python-ghostscript"
},
"split_keywords": [
"ghostscript",
"pdf",
"postscript"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "895bfa8ac3997ae33d631179ea2e972a5db358d5418b8cccbecfa4dc4c1f3b77",
"md5": "4d17bbdaf1bd899f1e53945bbe402a08",
"sha256": "97c70e27ba6b1cab4ab1d9b4cc82d89b8b53e57971f608ded4950b8aa20c78a7"
},
"downloads": -1,
"filename": "ghostscript-0.7-py2.py3-none-any.whl",
"has_sig": false,
"md5_digest": "4d17bbdaf1bd899f1e53945bbe402a08",
"packagetype": "bdist_wheel",
"python_version": "py2.py3",
"requires_python": null,
"size": 25327,
"upload_time": "2021-03-06T15:56:01",
"upload_time_iso_8601": "2021-03-06T15:56:01.093426Z",
"url": "https://files.pythonhosted.org/packages/89/5b/fa8ac3997ae33d631179ea2e972a5db358d5418b8cccbecfa4dc4c1f3b77/ghostscript-0.7-py2.py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "847308197d85f73b09843105c64231b0284965e7fae8ca7ce05c8c2674bbd583",
"md5": "73946e0695c8a763b48546242237f1a7",
"sha256": "b7875a87098740eb0be3de2d9662d15db727305ca9a6d4b7534a3cc33a4b965a"
},
"downloads": -1,
"filename": "ghostscript-0.7.tar.gz",
"has_sig": false,
"md5_digest": "73946e0695c8a763b48546242237f1a7",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 46557,
"upload_time": "2021-03-06T15:56:03",
"upload_time_iso_8601": "2021-03-06T15:56:03.115803Z",
"url": "https://files.pythonhosted.org/packages/84/73/08197d85f73b09843105c64231b0284965e7fae8ca7ce05c8c2674bbd583/ghostscript-0.7.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2021-03-06 15:56:03",
"github": false,
"gitlab": true,
"bitbucket": false,
"codeberg": false,
"gitlab_user": "pdftools",
"gitlab_project": "python-ghostscript",
"lcname": "ghostscript"
}