PGTS PGTS Pty. Ltd.   ACN: 007 008 568

point Site Navigation

point Other Blog Threads



  Valid HTML 4.01 Transitional

   Download Kubuntu Today

   Ubuntu

   The Power Of KDE + Ubuntu






PGTS Humble Blog

Thread: Tips/Tricks For Programming etc

Author Image Gerry Patterson. The world's most humble blogger
Edited and endorsed by PGTS, Home of the world's most humble blogger

Ghostscript For Cygwin


Chronogical Blog Entries:



Date: Wed, 11 Jun 2008 22:48:01 +1000

Although it is possible to get a version of ghostscript for windows, I prefer the command line version. I find that the cygwin version of ghostscript works quite well.

After installing ghostscript, you can use it more or less as you would in Linux. The ghostscript command is called gs. One way to get help is by entering

    gs --help
or
    gs -h

In the latest cygwin version there is some HTML documentation in the file /usr/share/doc/ghostscript-8.62/Use.htm. If you have w3m or lynx you can view it at the command line. Or you can open the file C:\cygwin\usr\share\doc\ghostscript-8.62\Use.htm with Firefox.

I found that an easy way to convert a PDF file to tiff was to use the following cygwin command:

    gs -sDEVICE=tiffg4 -r300 -sOutputFile=bar.tiff -dNOPAUSE -dBATCH foo.PDF

This command accomplishes the same thing with the -o option (see the documentation in the HTML file.):

    gs -sDEVICE=tiffg4 -r300 -obar.tiff foo.PDF

To convert a PDF to postscript:

    gs -q -sDEVICE=ps2write -sOutputFile=bar.ps -dNOPAUSE -dBATCH -dSAFER foo.PDF

Or use the -o option (which is an alias for -sOutputFile=bar.ps -dNOPAUSE -dBATCH -dSAFER).

To convert a PDF to postscript, I found I had to use something like the following:

    gs -dCompatibilityLevel=1.4 -sPAPERSIZE=a4 -q -sDEVICE=pdfwrite -obar.pdf -sPAPERSIZE=a4 -c .setpdfwrite -f bar.ps

In Australia, the default page size is more likely to be A4. And if you don't set the page size, the PDF has the ends chopped off.

There are several scripts installed with the standard cygwin ghostscript package. These are the scripts that usually ship with other unix distributions, such as ps2ascii, ps2epsi, ps2pdf, ps2pdfwr, ps2ps, ps2ps2, etc. These are shell scripts that run the /apps/bin/gs program with appropriate options. (/apps/bin/gs is actually a link). For example the command to convert a PDF (above) can be run with the ps2pdf script as follows:

    ps2pdf -sPAPERSIZE=a4 bar.ps bar.pdf

With ghostscript on cygwin you can accomplish many of the things in batch that you might do with Acrobat distiller. If you want performance however, you will have to use Unix (I recommend Ubuntu).


Other Blog Posts In This Thread:

Copyright     2008, Gerry Patterson. All Rights Reserved.