Announcing: python-ghostscript 0.3

H

Hartmut Goebel

Announcing:

python-ghostscript 0.3

A Python-Interface to the Ghostscript
C-API using ctypes

:Copyright: GNU Public License v3 (GPLv3)
:Author: Hartmut Goebel <[email protected]>
:Homepage: http://bitbucket.org/htgoebel/python-ghostscript
:Download: http://pypi.python.org/pypi/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://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.


Latest Changes
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

:0.3 (2010-08-12):

* Added support for win32: The DLL to load is searched in registry.

* On other platforms: Be more inteligent about finding Ghostscript
shared object file (fall back to ctypes.util.find_library() if
`libgs.8.so` can not be loaded

* Better error messages if lib/dll is not found.

* Removed relative imports, so older versions of Python can be used.

* Added nice project logo

:0.2 (2010-08-06):

* Fixed several bugs, esp. for running strings by Ghostscript.


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 ghostscript

args = [
"ps2pdf", # actual value doesn't matter
"-dNOPAUSE", "-dBATCH", "-dSAFER",
"-sDEVICE=pdfwrite",
"-sOutputFile=" + sys.argv[1],
"-c", ".setpdfwrite",
"-f", sys.argv[2]
]

ghostscript.Ghostscript(*args)

--
Regards
Hartmut Goebel

| Hartmut Goebel | (e-mail address removed) |
| www.crazy-compilers.com | compilers which you thought are impossible |
 
P

Peter Kleiweg

Hartmut Goebel schreef op de 12e dag van de oogstmaand van het jaar 2010:
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[1],
"-c", ".setpdfwrite",
"-f", sys.argv[2]
]

ghostscript.Ghostscript(*args)

How is this different from os.system(' '.join(args)) ?
 
P

Peter Kleiweg

Hartmut Goebel schreef op de 12e dag van de oogstmaand van het jaar 2010:
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[1],
"-c", ".setpdfwrite",
"-f", sys.argv[2]
]

ghostscript.Ghostscript(*args)

How is this different from os.system(' '.join(args)) ?
 
A

Aahz

Hartmut Goebel schreef op de 12e dag van de oogstmaand van het jaar 2010:
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[1],
"-c", ".setpdfwrite",
"-f", sys.argv[2]
]

ghostscript.Ghostscript(*args)

How is this different from os.system(' '.join(args)) ?

You don't have problems with shell metacharacters.
 
P

Peter Kleiweg

Aahz schreef op de 12e dag van de oogstmaand van het jaar 2010:
Hartmut Goebel schreef op de 12e dag van de oogstmaand van het jaar 2010:
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[1],
"-c", ".setpdfwrite",
"-f", sys.argv[2]
]

ghostscript.Ghostscript(*args)

How is this different from os.system(' '.join(args)) ?

You don't have problems with shell metacharacters.

Then use os.spawnv(os.P_WAIT, args[0], args)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top