[bug-pcl] reducing the size Ghostpcl generated PDFs

Stefan Kemper stefan.kemper at artifex.com
Wed Sep 29 11:00:45 PDT 2004


On Wed, 2004-09-29 at 11:31, Brian K. White wrote:
> Stefan Kemper wrote:
> > Jon,
> >
> > You might want to try:
> >
> > gs -sDEVICE=pdfwrite -sOutputFile=/home/jon/smaller.pdf bigger.pdf
> >
> > looking at the gs/doc/Ps2pdf.htm there are distiller parameters that
> > you can use to shrink the output pdf even more.
> 
> In that case, wouldn't it be better to have pcl6 output ps instead of pdf 
> and pipe it into gs ?

pdfwrite is a high level device pswrite is a lowlevel device.

pcl -> pdf -> pdf  will give you nice small pdfs

pcl -> ps -> gives very large files

pcl -> ps -> pdf will also give large files

> On my systems I have the following two pcl6 wrappers, both based on 
> pcl2pdfwr but I dispensed with the extra layer of having pcl2pdf run 
> pcl2pdfwr and just renamed pcl2pdfwr to pcl2pdf. Then copied that to pcl2ps 
> and edited appropriately.

> I use pcl2ps mostly to pipe legacy apps hplaser output right into hylafax. 
> Slick!
> Thank you Artifex!
> 
> I noticed along the way that pcl6 generates ps a lot faster than it 
> generates pdf.

yes the pdfwrite device is slow.

> Understandable and expected. I'm sure it has to generate ps every time and 
> the pdf is just more processing after that.

No generating ps will make everything into small vector fills and
raster.  This is fast but takes lots of space.

Pdfwrite stores high level vectors, fonts, images etc.  This is slow to
generate but can generate much smaller output.

The second step of running gs to convert a pdf into a smaller pdf is
just reducing the resolution of raster images and patterns from 600dpi
to 72dpi with lossy comression.

> So, if it were me, I'd see if this doesn't run faster than creating a bad 
> pdf and the converting it to a better pdf:
> pcl2ps invoice.pcl - |gs -sDEVICE=pdfwrite -sOutputFile=invoice.pdf -
> 
> If it works and produces better output and doesn't run too much slower than 
> the built-in pdfwriter, I suggest simply editing pcl2pdf.
> 
> Maybe that is the most sensible way to go for other reasons too. It seems a 
> waste to have to keep pcl6 up to date with all of ghostscript, and/or live 
> without things. Just junk all the 200 output drivers and focust on the 
> pcl-ps engine and let the external gs interpret the ps.
> They really are two distinct jobs and better served by two seperate tools. 
> That should make your jobs easier maintaining the code and users get the 
> benefit of always using the latest gs (or ImageMagic or commercial ps 
> interpreter / pdf distiller or whatever they want) to turn the ps into 
> whatever. Maybe pcl6 shouldn't even have a -sDEVICE option?
> 

If our pswrite stored high level objects you would have a point but
since that project isn't finished I wouldn't try this approach.



> pcl2ps
> ------------------------------------
> #!/bin/sh
> # Copied from pcl2pdfwr
> # Convert PCL or PXL to PS
> # Handy for feeding legacy application print data into hylafax.
> # brian at aljex.com 2004-06-20
> 
> OPTIONS=
> while true
> do
>  case "$1" in
>  -?*) OPTIONS="$OPTIONS $1" ;;
>  *)  break ;;
>  esac
>  shift
> done
> 
> if [ $# -lt 1 -o $# -gt 2 ]; then
>  echo "Usage: `basename $0` [options...] (input.pcl|-) [output.ps|-]" 1>&2
>  exit 1
> fi
> 
> infile=$1;
> 
> if [ $# -eq 1 ]
> then
>  case "${infile}" in
>    -)  outfile=- ;;
>    *.pcl) base=`basename ${infile} .pcl`; outfile=${base}.ps ;;
>    *.pxl) base=`basename ${infile} .pxl`; outfile=${base}.ps ;;
>    *)  base=`basename ${infile}`; outfile=${base}.ps ;;
>  esac
> else
>  outfile=$2
> fi
> 
> # We have to include the options twice because -I only takes effect if it
> # appears before other options.
> exec pcl6 $OPTIONS  -dNOPAUSE -dBATCH -sDEVICE=pswrite -sOutputFile=$outfile 
> $OPTIONS $infile
> -------------------------------
> 
> 
> 
> 
> my current pcl2pdf:
> ----------------------------------------
> #!/bin/sh
> # $RCSfile: pcl2pdfwr,v $ $Revision: 1.2 $
> # Convert PCL or PXL to PDF without specifying CompatibilityLevel.
> 
> OPTIONS=
> while true
> do
>  case "$1" in
>  -?*) OPTIONS="$OPTIONS $1" ;;
>  *)  break ;;
>  esac
>  shift
> done
> 
> if [ $# -lt 1 -o $# -gt 2 ]; then
>  echo "Usage: `basename $0` [options...] (input.pcl|-) [output.pdf|-]" 1>&2
>  exit 1
> fi
> 
> infile=$1;
> 
> if [ $# -eq 1 ]
> then
>  case "${infile}" in
>    -)  outfile=- ;;
>    *.pcl) base=`basename ${infile} .pcl`; outfile=${base}.pdf ;;
>    *.pxl) base=`basename ${infile} .pxl`; outfile=${base}.pdf ;;
>    *)  base=`basename ${infile}`; outfile=${base}.pdf ;;
>  esac
> else
>  outfile=$2
> fi
> 
> # We have to include the options twice because -I only takes effect if it
> # appears before other options.
> exec pcl6 
> $OPTIONS  -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=$outfile $OPTIONS 
> $infile
> ------------------------------------
> 
> 
> 
> proposed new pcl2pdf:
> ----------------------------------------
> #!/bin/sh
> # $RCSfile: pcl2pdfwr,v $ $Revision: 1.3 $
> # Convert PCL or PXL to PDF without specifying CompatibilityLevel.
> # only use pcl6 to render the pcl into ps
> # pipe into gs to render the ps into pdf
> 
> OPTIONS=
> while true
> do
>  case "$1" in
>  -?*) OPTIONS="$OPTIONS $1" ;;
>  *)  break ;;
>  esac
>  shift
> done
> 
> if [ $# -lt 1 -o $# -gt 2 ]; then
>  echo "Usage: `basename $0` [options...] (input.pcl|-) [output.pdf|-]" 1>&2
>  exit 1
> fi
> 
> infile=$1;
> 
> if [ $# -eq 1 ]
> then
>  case "${infile}" in
>    -)  outfile=- ;;
>    *.pcl) base=`basename ${infile} .pcl`; outfile=${base}.pdf ;;
>    *.pxl) base=`basename ${infile} .pxl`; outfile=${base}.pdf ;;
>    *)  base=`basename ${infile}`; outfile=${base}.pdf ;;
>  esac
> else
>  outfile=$2
> fi
> 
> # We have to include the options twice because -I only takes effect if it
> # appears before other options.
> exec pcl6 $OPTIONS  -dNOPAUSE -dBATCH -sDEVICE=pswrite -sOutputFile=- 
> $OPTIONS $infile 
> |gs -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=$outfile -
> 
> ------------------------------------
> 
> --
> Brian K. White  --  brian at aljex.com  --  http://www.aljex.com/bkw/
> +++++[>+++[>+++++>+++++++<<-]<-]>>+.>.+++++.+++++++.-.[>+<---]>++.
> filePro BBx  Linux SCO  Prosper/FACTS AutoCAD  #callahans Satriani
> 
> _______________________________________________
> bug-pcl mailing list
> bug-pcl at ghostscript.com
> http://www.ghostscript.com/mailman/listinfo/bug-pcl
> 



More information about the bug-pcl mailing list