Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ghostscript

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ghostscript

Interface to the Ghostscript C-API, both high- and low-level, based on ctypes

  • 0.7
  • PyPI
  • Socket score

Maintainers
1

========================== 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:

Keywords

FAQs


Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc