Subject: Ghostscript/PDF-files/ghostview

From: Maarten Boekhold <[email-masked]>
Date: Mon, 22 Jul 1996 22:24:40 +0200 (MET DST)

Hello,

I remember seeing some discussion on this list (or debian-user, not sure)
about ghostscript and handling PDF-files (Acrobat-files).

Somebody said something about drivers or something needed if I remember
correctly. Now, today, I fired up gs-3.53 with '-h' as argument, and saw
that a language-interpreter for PDF-files is compiled in. 'use.doc' said
that operation with ghostview is not really possible, caused by ghostview
sending data to gs by a pipe.

Also according to that doc, a patched version of ghostview exists, which
handles this correctly:

quote:

Since Ghostview pipes PostScript files to Ghostscript, you cannot
view Ghostscript files with Ghostview just by saying
        ghostview file.pdf Instead there are two options: 
   1. Tanmoy Bhattacharya has written some patches for Ghostview 1.5
   that allow it to read and display PDF files.  These are available
   from: 
       ftp://gita.lanl.gov/people/tanmoy/hypertex/gv1.5gs3.33hack.tar.gz

Question to the ghostview-maintainer: wouldn't it be a good idea to use
this version of ghostview for the next release? I don't think it will
cause any problems for ppl who have gs-2.61 installed instead of 3.53.

Maarten

_______________________________________________________________________ 
|    Maarten Boekhold, Faculty of Electrical Engineering TU Delft, NL | 
|     [email-masked] [email-masked] |
-----------------------------------------------------------------------

---

From: Yves Arrouye <[email-masked]>
Date: Tue, 23 Jul 1996 23:59:06 +0200

> Also according to that doc, a patched version of ghostview exists, which

This hacked 1.5 version of Ghostview worked with 3.33 and stopped working
starting with 3.51. We are at 4.01 now... And the last time I checked
the prologue sent to gs by this ghostview made it barf.

(But I'd *love* to have a ghostview-based PDF viewer...)

Yves.

---

From: [email-masked] (Emilio Lopes)
Date: Wed, 24 Jul 96 19:31 EST

>>>>> "YA" == Yves Arrouye <[email-masked]> wrote:

>> Also according to that doc, a patched version of ghostview exists, which

YA> This hacked 1.5 version of Ghostview worked with 3.33 and stopped
YA> working starting with 3.51. We are at 4.01 now... And the last
YA> time I checked the prologue sent to gs by this ghostview made it
YA> barf.

YA> (But I'd *love* to have a ghostview-based PDF viewer...)

I remeber I've heard about a port to Unix of the VMS port of
ghostview. That may sound ridiculous, but the fact is that someone
added pdf support to the VMS port of ghostview, but not to the
original (Unix) ghostview.

I'm pretty sure I've read this somewhere, but can't remember
where.

Ciao, Emilio.

-- 
                 Emilio C. Lopes <mailto:[email-masked]>
               Instituto de Fisica da Universidade de Sao Paulo
             Caixa Postal 66318, 05389-970 Sao Paulo - SP, BRAZIL
              Phone: (+55) (11) 818-6724 (Voice) / 818-6715 (Fax)

---

From: "Susan G. Kleinmann" <[email-masked]>
Date: Thu, 25 Jul 1996 06:01:00 -0400

> I'm pretty sure I've read this somewhere, but can't remember

[email-masked] (Ronan MELENNEC) wrote on 7/18 in comp.text.pdf:
"It is in the works (Ghostview 2.7 beta 3).
 This is done by Johannes Plass <[email-masked]>.

 There might be a copy of the sources on Linux FTP mirrors.
 Otherwise, try `ftp://ftp.cena.dgac.fr/pub/doc-tools/ghostview'.

 For PDF files, it is not as pretty as Acrobat nor as fast as XPDF,
 but it works. Plus, it can also display PostScript files :-)"

HTH,
Susan Kleinmann
[email-masked]

---

From: [email-masked] (J.H.M.Dassen)
Date: Thu, 25 Jul 1996 15:49:57 +0200 (MDT)

> YA> (But I'd *love* to have a ghostview-based PDF viewer...)

Does this help? [gs FAQ at http://www.cs.wisc.edu/~ghost/gsfaq.txt]:
Subject: 1.12 How do you display PDF files with Ghostview?

   Since Ghostview pipes PostScript files to Ghostscript, you
   cannot start Ghostview as
          ghostview file.pdf
   Instead there are several options:

   2. Start Ghostview as follows:
          ghostview -arguments file.pdf quit.ps
   This will allow you to display a PDF file, but you won't be able
   to jump to particular pages.  Use Tanmoy's code if you want that
   facility.

   3. With ghostscript 3.53 or later, create an `index file' by saying
          pdf2dsc file.pdf file.pdx
          ghostview file.pdx
   This lets you display particular pages of a pdf file even without a
   patched version of ghostview. The index file isn't a postscript
   version of the pdf file, just a series of commands to ghostscript
   saying `display page 1 of file.pdf', `display page 2', and so on.

Ray
-- 
POPULATION EXPLOSION  Unique in human experience, an event which happened 
yesterday but which everyone swears won't happen until tomorrow.  
- The Hipcrime Vocab by Chad C. Mulligan

---

From: Helmut Geyer <[email-masked]>
Date: Thu, 25 Jul 1996 20:35:23 +0200 (MET DST)

> cause any problems for ppl who have gs-2.61 installed instead of 3.53.

Well, I looked at it some months ago, but it had some disadvantages with
some versions of gs and, what's more important, xpdf is much faster.
So I'm not sure I want to do this. Install xpdf to view PDF files and use
ghostview for real PostScript. We have good viewers for both formats, so
why should we use a hack to add PDF format to the PostScript viewer?

	Helmut

------------------------------------------------------------------------------
Helmut Geyer                                [email-masked]

---

From: Yves Arrouye <[email-masked]>
Date: Thu, 25 Jul 1996 22:07:55 +0200

>    saying `display page 1 of file.pdf', `display page 2', and so on.

But there is no pdf2sc in the gs4.01 distribution. Here is one, along
with its manual page, that will maybe find their way into a ghostscript
package...

Now it's easy to write a wrapper for ghostview, too...

Yves.

#!/bin/sh
# This is a shell archive (produced by GNU sharut 4.2.1).
# To extract the files from this archive, save it to some FILE, remove
# everything before the `!/bin/sh' line above, then type `sh FILE'.
#
# Made on 1996-07-25 18:23 MET DST by <root@marin>.
# Source directory was `/usr/local/src/ghostscript/yves'.
#
# Existing files will *not* be overwritten unless `-c' is specified.
#
# This shar contains:
# length mode       name
# ------ ---------- ------------------------------------------
#    395 -rwxr-xr-x pdf2dsc
#   1374 -rw-r--r-- pdf2dsc.1
#
save_IFS="${IFS}"
IFS="${IFS}:"
gettext_dir=FAILED
locale_dir=FAILED
first_param="$1"
for dir in $PATH
do
  if test "$gettext_dir" = FAILED && test -f $dir/gettext \
     && ($dir/gettext --version >/dev/null 2>&1)
  then
    set `$dir/gettext --version 2>&1`
    if test "$3" = GNU
    then
      gettext_dir=$dir
    fi
  fi
  if test "$locale_dir" = FAILED && test -f $dir/shar \
     && ($dir/shar --print-text-domain-dir >/dev/null 2>&1)
  then
    locale_dir=`$dir/shar --print-text-domain-dir`
  fi
done
IFS="$save_IFS"
if test "$locale_dir" = FAILED || test "$gettext_dir" = FAILED
then
  echo=echo
else
  TEXTDOMAINDIR=$locale_dir
  export TEXTDOMAINDIR
  TEXTDOMAIN=sharutils
  export TEXTDOMAIN
  echo="$gettext_dir/gettext -s"
fi
if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then
  if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then
    shar_n= shar_c='
'
  else
    shar_n=-n shar_c=
  fi
else
  shar_n= shar_c='\c'
fi
touch -am 1231235999 $$.touch >/dev/null 2>&1
if test ! -f 1231235999 && test -f $$.touch; then
  shar_touch=touch
else
  shar_touch=:
  echo
  $echo 'WARNING: not restoring timestamps.  Consider getting and'
  $echo "installing GNU \`touch', distributed in GNU File Utilities..."
  echo
fi
rm -f 1231235999 $$.touch
#
$echo $shar_n 'x -' 'lock directory' "\`_sh05981': "$shar_c
if mkdir _sh05981; then
  $echo 'created'
else
  $echo 'failed to create'
  exit 1
fi
# ============= pdf2dsc ==============
if test -f 'pdf2dsc' && test "$first_param" != -c; then
  $echo 'x -' SKIPPING 'pdf2dsc' '(file already exists)'
else
  $echo 'x -' extracting 'pdf2dsc' '(text)'
  sed 's/^X//' << 'SHAR_EOF' > 'pdf2dsc' &&
#! /bin/sh
X
# psf2dsc: generates an index of a PDF file.
#
# Yves Arrouye <[email-masked]>, 1996.
X
me=`basename $0`
X
usage() {
X    >&2 echo usage: $me "pdffile [ dscfile ]"
X    exit 1
}
X
if [ $# -gt 2 ]
then
X    usage
fi
X
pdffile=$1
dscfile=$2
: ${dscfile:=`echo $pdffile | sed 's,\.[^/.]*,,'`.dsc}
X
exec gs -q -dNODISPLAY \
X    -sPDFname="$pdffile" -sDSCname="$dscfile" pdf2dsc.ps -c quit
X
SHAR_EOF
  $shar_touch -am 0725182196 'pdf2dsc' &&
  chmod 0755 'pdf2dsc' ||
  $echo 'restore of' 'pdf2dsc' 'failed'
  if ( md5sum --help </dev/null 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
  && ( md5sum --version </dev/null 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
    md5sum -c << SHAR_EOF >/dev/null 2>&1 \
    || $echo 'pdf2dsc:' 'MD5 check failed'
e00271b4ef5472829c8b4a9df533c876  pdf2dsc
SHAR_EOF
  else
    shar_count="`LC_ALL=C wc -c < 'pdf2dsc'`"
    test 395 -eq "$shar_count" ||
    $echo 'pdf2dsc:' 'original size' '395,' 'current size' "$shar_count!"
  fi
fi
# ============= pdf2dsc.1 ==============
if test -f 'pdf2dsc.1' && test "$first_param" != -c; then
  $echo 'x -' SKIPPING 'pdf2dsc.1' '(file already exists)'
else
  $echo 'x -' extracting 'pdf2dsc.1' '(text)'
  sed 's/^X//' << 'SHAR_EOF' > 'pdf2dsc.1' &&
X.\" pdf2dsc.1: short documentation for pdf2dsc
X.\" Yves Arrouye <[email-masked]>
X.TH PDF2DSC 1 "25 July 1996" "Ghostscript 4" "Ghostscript Tools"
X.SH NAME 
X.B pdf2dsc
\- generate a PS page list of a PDF document
X.SH SYNOPSIS
X.B pdf2dsc
X.I pdffile
[
X.I dscfile
]
X.SH DESCRIPTION
X.B pdf2dsc
reads a Portable Document Format (PDF) document 
X.I pdffile
and creates a PostScript document
X.I dscfile
that conforms to Adobe's Document Structuring Conventions (DSC)
requirements.
This new document simply tells Ghostscript to read the PDF file and to
display pages one at a time.
X.PP
The generated document can then be viewed with any PostScript viewer
based on Ghostscript, like
X.BR ghostview (1)
or
X.BR GSView ,
which will let the user browse through the pages of the PDF document
in any order.
X.PP
If the output document name
X.I dscfile
is not given on the command line, the name used is
X.I pdffile
with any extension removed, followed by a
X.B .dsc
extension.
X.SH CAVEATS
The DSC document uses Ghostscript-specific procedures.
In addition, the original PDF document must be accessible when the
DSC document is read.
X.PP
You need the
X.B pdf2dsc.ps
file (originally by Russell Lang) that comes with Ghostscript releases
3.53 and higher and a corresponding Ghostscript interpreter.
X.SH DOCUMENTATION
Yves Arrouye <[email-masked]>
X.SH SEE ALSO
X.BR gs (1),
X.BR ghostview (1)
X
SHAR_EOF
  $shar_touch -am 0725182196 'pdf2dsc.1' &&
  chmod 0644 'pdf2dsc.1' ||
  $echo 'restore of' 'pdf2dsc.1' 'failed'
  if ( md5sum --help </dev/null 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
  && ( md5sum --version </dev/null 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
    md5sum -c << SHAR_EOF >/dev/null 2>&1 \
    || $echo 'pdf2dsc.1:' 'MD5 check failed'
e391629f4b089a0f789b15b4700c49eb  pdf2dsc.1
SHAR_EOF
  else
    shar_count="`LC_ALL=C wc -c < 'pdf2dsc.1'`"
    test 1374 -eq "$shar_count" ||
    $echo 'pdf2dsc.1:' 'original size' '1374,' 'current size' "$shar_count!"
  fi
fi
$echo $shar_n 'x -' 'lock directory' '_sh05981:' $shar_c
if rm -fr _sh05981; then
  $echo 'removed'
else
  $echo 'failed to remove'
exit 0