Announcing: python-ghostscript 0.3

Discussion in 'Python' started by Hartmut Goebel, Aug 12, 2010.

  1. Announcing:

    python-ghostscript 0.3

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

    :Copyright: GNU Public License v3 (GPLv3)
    :Author: Hartmut Goebel <>
    :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 | |
    | www.crazy-compilers.com | compilers which you thought are impossible |
    Hartmut Goebel, Aug 12, 2010
    #1
    1. Advertising

  2. 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)) ?



    --
    Peter Kleiweg L:NL,af,da,de,en,ia,nds,no,sv,(fr,it) S:NL,de,en,(da,ia)
    info: http://www.let.rug.nl/kleiweg/ls.html
    Peter Kleiweg, Aug 12, 2010
    #2
    1. Advertising

  3. 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)) ?



    --
    Peter Kleiweg L:NL,af,da,de,en,ia,nds,no,sv,(fr,it) S:NL,de,en,(da,ia)
    info: http://www.let.rug.nl/kleiweg/ls.html
    Peter Kleiweg, Aug 12, 2010
    #3
  4. Hartmut Goebel

    Aahz Guest

    In article <alpine.DEB.1.10.1008121733280.3749@localhost>,
    Peter Kleiweg <> wrote:
    >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.
    --
    Aahz () <*> http://www.pythoncraft.com/

    "...if I were on life-support, I'd rather have it run by a Gameboy than a
    Windows box." --Cliff Wells
    Aahz, Aug 12, 2010
    #4
  5. Aahz schreef op de 12e dag van de oogstmaand van het jaar 2010:

    > In article <alpine.DEB.1.10.1008121733280.3749@localhost>,
    > Peter Kleiweg <> wrote:
    > >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)



    --
    Peter Kleiweg L:NL,af,da,de,en,ia,nds,no,sv,(fr,it) S:NL,de,en,(da,ia)
    info: http://www.let.rug.nl/kleiweg/ls.html
    Peter Kleiweg, Aug 12, 2010
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Christopher Campbell

    Ghostscript locking files in ASP.NET

    Christopher Campbell, Oct 15, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    2,086
    Jacob Yang [MSFT]
    Oct 16, 2003
  2. SpamProof

    ghostscript leaves windword processes

    SpamProof, Feb 24, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    364
    SpamProof
    Feb 25, 2004
  3. Sjaakie

    ASP.NET and GhostScript

    Sjaakie, May 10, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    1,595
    Sjaakie
    May 10, 2006
  4. Mark Hahn
    Replies:
    22
    Views:
    645
    Carlos Ribeiro
    Sep 9, 2004
  5. Hartmut Goebel

    [ANN] python-ghostscript 0.4

    Hartmut Goebel, Jan 29, 2011, in forum: Python
    Replies:
    0
    Views:
    408
    Hartmut Goebel
    Jan 29, 2011
Loading...

Share This Page