Problem with 'pdftops' filter

Kevin Ivory Ivory at SerNet.de
Fri May 6 05:48:24 PDT 2005


On 2005-05-05 01:40, Julien Bossert wrote:
> I passed a PDF A4 file through '/usr/bin/pdftops' and then I transformed
> the resulting PS file with 'mpage -2 -bA4' to obtain a second PS file.

we had that problem with mpage once as well and found the letter default
somewhere deeply nested in one of the files. Do you really need mpage?
Doesn't "-o number-up=2" do what you need?

> When I try to print this second PS file with duplex mode, the printer asks me to change a mechanical switch's position from "A4" to "LTR/LGL": the printer believes I'm using letter or legal paper?
> 
> The resulting printing is shifted on recto and on not verso, but there the bottom of the page content is cropped leaving a blank on the paper.

Here are two short skripts that might help you either debugging or
might even solve your problems as is.

1. a short skript which you can use to switch between cups-pdftops,
gs-pdf2ps and acroread (Adobe reader). In each of them I tried to
force A4 paper with options. If you use mypdftops in /etc/cups/mime.convs,
you can choose between "-o pdf=acro", "-o pdf=gs" or "-o pdf=cups" [default].

#!/bin/bash
# /usr/lib/cups/filter/mypdftops
# There are three methods of converting PDF to PS:
# cups=pdftops, acro, gs=pdf2ps.
# I have never seen 5 arguments used. (tested: lpr < t.pdf, lpr t.pdf)
case $# in
  5|6 ) ;;
  *   ) echo "Usage: $0 job-id user title copies options [filename]"; exit ;;
esac
DEBUG=0
# LOGDIR must be writable by user lp (only needed when DEBUG not set to 0)!
LOGDIR=/var/log/cups
acrobin="/usr/X11R6/bin/acroread"
acroopt="-toPostScript -size a4"
cupsbin="/usr/lib/cups/filter/pdftops"
gsbin="/opt/ghostscript/bin/gs"
gsopt="-q -dLanguageLevel=2 -dNOPAUSE -dBATCH -dPARANOIDSAFER -sDEVICE=pswrite"
gsopt="$gsopt -sPAPERSIZE=a4 -sOutputFile=-"
if [ $DEBUG -ne 0 ]; then
  time=$(unset TZ;LC_TIME=de_DE date)
  log="$1 $0 $time \$#=$#\nuser: $2\ttitle: $3"
  [ "$4" -ne "1" ] && log="$log\ncopies: $4"
  [ "$5"  != ""  ] && log="$log\noptions: $5"
  [ "$#" -eq "6" ] && log="$log\nfilename: $6"
  echo -e "$log\n" >> $LOGDIR/cups.parameter
fi
case "$5" in
  *acro* )
    $acrobin $acroopt < "$6"
    ;;
  *pdf=gs* | *pdf=pdf2ps* )
    $gsbin $gsopt -f "$6"
    ;;
  * | *pdf=cups* | *pdf=xpdf* | *pdf=pdftops* )
    $cupsbin "$@"
    ;;
esac

2. a short skript for page-rearranging (use mypstops in mime.convs),
use a newly defined "-o book" option.
If you need the mpage for some kind of page resorting, we have something
similar using the psbook tool from the psutils package:

#!/bin/bash
# /usr/lib/cups/filter/mypstops
# Cups filter which accepts option "book" and resorts output if supplied.
case $# in
  5|6 ) ;;
  *   ) echo "Usage: $0 job-id user title copies options [filename]"; exit ;;
esac
DEBUG=0
# LOGDIR must be writable by user lp (only if DEBUG not set to 0)!
LOGDIR=/var/log/cups
psbook=/usr/bin/psbook
pstops=/usr/lib/cups/filter/pstops
case "$5" in
  *book* ) book=y ;;
  *      ) book=n ;;
esac
# 2003-07-18 ki problems with some PS-files when LANG is set :-(
unset LANG LANGUAGE LC_ALL
if [ "$DEBUG" -ne 0 ]; then
  time=$(unset TZ;LC_TIME=de_DE date)
  log="$1 $0 $time \$#=$#\nuser: $2\ttitle: $3"
  [ "$4" -ne "1" ] && log="$log\ncopies: $4"
  [ "$5"  != ""  ] && log="$log\noptions: $5"
  [ "$#" -eq "6" ] && log="$log\nfilename: $6"
  echo -e "$log\n" >> $LOGDIR/cups.parameter
fi
#cat > $LOGDIR/cups.out
if [ "$book" == "n" ]; then
  $pstops "$@"
else
  case $# in
    5 ) $psbook -q | $pstops "$@" ;;
    6 ) $psbook -q "$6" | $pstops "$1" "$2" "$3" "$4" "$5" ;;
  esac
fi

Perhaps these simple skripts can help you getting around your
problem. Or fit them to do more debugging and you will probably
be able to find the cause of your problem.

Kevin
-- 
   _             |  Kevin Ivory          |  Tel: +49-551-3700000
  |_     |\ |    |  Service Network GmbH |  Fax: +49-551-3700009
  ._|ER  | \|ET  |  Bahnhofsallee 1b     |  mailto:Ivory at SerNet.de
 Service Network |  37081 Goettingen     |    http://www.SerNet.de/




More information about the cups mailing list