handyfloss

Because FLOSS is handy, isn’t it?

Convert PS to PDF

Posted by isilanes on July 27, 2006

I make extensive use of ps2pdf to convert PostScript files to PDF. As most GNU/Linux tools, this is a simple and incredibly useful one.

However, sometimes it might give problems. For example, I have sometime converted a PS to a PDF that Evince would open fine, but Acrobat Reader would not. I fixed this problem making use of the superb alternatives system present in Debian.

The first thing to know is that most of PS and PDF manipulation (including PS-to-PDF conversion) is done by calling a backend application called Ghostscript (GS). A quick search within the Debian packages shows that most (if not all) of the GS versions mentioned in the wikipedia page are available:

Bart[~/]: aptitude search ^gs-
i   gs-afpl                     - The AFPL Ghostscript PostScript interpreter
p   gs-aladdin                  - Transitional package
p   gs-cjk-resource             - Resource files for gs-cjk, ghostscript CJK-TrueType extension
i A gs-common                   - Common files for different Ghostscript releases
i A gs-esp                      - The Ghostscript PostScript interpreter - ESP version
p   gs-gpl                      - The GPL Ghostscript PostScript interpreter
v   gs-pdfencrypt               -

It turns out I was using gs-esp:

Bart[~/]: which gs
/usr/bin/gs
Bart[~/]: ls -l /usr/bin/gs
lrwxrwxrwx 1 root root 20 Jul  4 09:00 /usr/bin/gs -> /etc/alternatives/gs*
Bart[~/]: ls -l /etc/alternatives/gs
lrwxrwxrwx 1 root root 16 Jul 27 11:26 /etc/alternatives/gs -> /usr/bin/gs-esp

I remember having used different GS versions, and AFPL being the “best”, so I installed it and made the default gs point to it, with the Debian alternatives system (as root):

Bart:~# aptitude install gs-afpl
[...]
Bart:~# update-alternatives --config gs

There are 2 alternatives which provide `gs'.

  Selection    Alternative
  -----------------------------------------------
  * +   1        /usr/bin/gs-esp      
        2        /usr/bin/gs-afpl

Press enter to keep the default[*], or type selection number:

There, I just pressed “2”, et voilĂ ! Now my default GS is gs-afpl, and ps2pdf makes use of it. Any other GS version one could want to use, the procedure to change it would be the same.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: