[pdftex] Duplex printing?

Hans Hagen pragma at wxs.nl
Thu Feb 16 09:55:34 CET 2006


Robin Fairbairns wrote:
>>> You can't embed some magic in a pdf that will force it to print
>>> duplex. At least nothing that could be used by normal printers.
>>>       
>> This isn't a "normal" printer and is quite happy to print duplex from
>> openoffice. But
>> something in pdftex output turns the duplex feature off.  The ppd file tells
>> me exactly what to put in a postscript file to turn duplex on (or off). If worse
>> comes to worse, I will convert the pdf to ps and insert the stuff with a little
>> script, but I can't quite believe that I'm the first person in the world to want
>> to use pdftex with a duplex capable postscript printer and that noone
>> has implemented
>> this.
>>     
>
> none of our kyocera printers (fs3820 x2, 5016 x3 and 9520 x2)
> accept anything other than postscript (though they call it kpdl:
> presumably they've "enhanced" postscript and can't bear not to have
> their name in it).  they all have duplexers (and the 9520s have
> staplers).
>
> how are you outputting to the printer?  indeed, what operating system
> are you using?
>
> since you talk about a ppd, i wonder if you're being fooled by the
> insane printer drivers that they supply for use under widnoze? -- i
> was for quite a while.  if you _are_ using widnoze, i could possibly
> help you.
>
> if you're using linux, i could talk to our guy who modified our print
> spooler for the new printers (we've had them <2 years -- just got fed
> up with hp's appalling service and have sworn off buying hp).
>   
normally the printer driver does this (esp when printing from acrobat)

an alternative is to ise pdftops (xpdf suite) and pipe the additional 
settings directly to the printer followed by the ps stream; this is 
rather os indepedent

Here is a setup for an oce3165 postscript (duplex) printer; there are 
some hard coded numbers in there

# PRAGMA ADE / OCE 3165 PRINTING

# %!OCE *JEC BEGIN
# %!OCE IDENT:
# %!OCE     EMULATION POSTSCRIPT
# %!OCE     JOBDATE 6-7-1998
# %!OCE     JOBNAME JSIT e:\tex\pragma\sources\test.ps
# %!OCE     JOBTYPE AUTOMATIC
# %!OCE     USERNAME oce_3165
# %!OCE     HOSTNAME pragmaserver
# %!OCE     GROUPNAME PRAGMA
# %!OCE PROCESS:
# %!OCE     COPIES 1
# %!OCE     PRINTQUALITY HALFTONE 2
# %!OCE     BIND LONGEDGE FRONT 0 BACK 0
# %!OCE     FLAGSHEET AUTOMATIC HEADER
# %!OCE *JEC BODY

use Getopt::Long ;

$Getopt::Long::passthrough = 1 ; # no error message
$Getopt::Long::autoabbrev  = 1 ; # partial switch accepted

$PrinterPath = "10.100.1.20" ;
$PrinterPort = "print" ;

$S_Copies = 1;
$S_Duplex = "OFF";
$S_Tray   = 1;
$S_Staple = "OFF";

&GetOptions
  ( "copies=s"  => \$Copies ,
    "duplex"    => \$Duplex ,
    "tray=s"    => \$Tray   ,
      "normal"    => \$Normal_Tray,
      "a4"        => \$A4_Tray,
      "company"   => \$Company_Tray,
      "a3"        => \$A3_Tray,
      "envelop"   => \$Envelop_Tray,
    "staple"    => \$Staple ,
    "pdf"       => \$Pdf ,
    "dvi"       => \$Dvi ,
    "help"      => \$Help   ) ;

$Program = "OcePrint 1.03 - ConTeXt / PRAGMA 1997-2000" ;

print "\n$Program\n\n";

if (($Help) || !(@ARGV))
  { print
      "               --copies   number of copies                \n" .
      "               --duplex   turn duplex printing on         \n" .
      "                 --tray   tray to print from              \n" .
      "                            = normal a4 company a3 envelop\n" .
      "                  --pdf   convert pdf to ps               \n" ;
      "                  --dvi   convert dvi to ps               \n" ;
      "               --staple   staple the results              \n" ;
    exit }

$Trays{"normal"}  = 1 ;
$Trays{"nor"}     = 1 ;
$Trays{"a4"}      = 1 ;
$Trays{"company"} = 2 ;
$Trays{"com"}     = 2 ;
$Trays{"a3"}      = 3 ;
$Trays{"envelop"} = 4 ;
$Trays{"env"}     = 4 ;

if ($Copies)
  { $S_Copies = $Copies }

if ($Duplex)
  { $S_Duplex = "ON" }

if    ($Normal_Tray)
  { $S_Tray = $Trays{"normal"} }
elsif ($A4_Tray)
  { $S_Tray = $Trays{"a4"} }
elsif ($Company_Tray)
  { $S_Tray = $Trays{"company"} }
elsif ($A3_Tray)
  { $S_Tray = $Trays{"a3"} }
elsif ($Envelop_Tray)
  { $S_Tray = $Trays{"envelop"} }
elsif ($Tray)
  { if ($Trays{$Tray})
      { $S_Tray = $Trays{$Tray} }
    else
      { $S_Tray = $Tray } }

if ($Staple)
  { $S_Staple = "ON" }

print
  "       number of copies : $S_Copies \n"   .
  "        duplex printing : $S_Duplex \n"   .
  "             paper tray : $S_Tray   \n"   .
  "                 staple : $S_Staple \n\n" ;

$Sequence = "%!OCE *JEC BEGIN             \n" .
            "%!OCE IDENT:                 \n" .
            "%!OCE   EMULATION POSTSCRIPT \n" .
            "%!OCE PROCESS:               \n" .
            "%!OCE   COPIES $S_Copies     \n" .
            "%!OCE   DUPLEX $S_Duplex     \n" .
            "%!OCE   TRAY   $S_Tray       \n" .
            "%!OCE   STAPLE $S_Staple     \n" .
            "%!OCE *JEC BODY              \n" .
            "%PS                          \n" ;

foreach (@ARGV)
  { if (/\.pdf/io)
      { $Pdf = 1 }
    elsif (/\.dvi/io)
      { $Dvi = 1 }
    elsif (/\.ps/io)
      { }
    elsif ($Pdf)
      { $_ .= ".pdf" }
    elsif ($Dvi)
      { $_ .= ".dvi" }
    else
      { $_ .= ".ps" } }

my @files = glob $ARGV[0] ;

foreach (@files) # can be done more efficient, quick hack
  { my $remove = "" ;
    if (/\.pdf$/io)
      { $_ =~ s/\.pdf$//io ;
        $remove = 1 ;
        $filename = "$_.ps" ;
        unlink $filename ;
        print "  start converting file : $_.pdf (using pdftops)\n" ;
        $ok = system ("pdftops $_.pdf $filename") ;
        if (-e $filename) { $ok = "done" } else { $ok = "error" }
        print "        converting file : $ok\n" }
    elsif (/\.ps$/io)
      { $filename = $_ }
    else
      { $filename = "$_.ps" }
    #~ if (open (DATA,$filename))
      #~ { binmode DATA ;
        #~ print "          printing file : $filename\n" ;
        #~ open (PRINTER, ">$PrinterPath") ;
        #~ binmode PRINTER ;
        #~ print PRINTER $Sequence ;
        #~ while (<DATA>)
          #~ { print PRINTER $_ }
        #~ close (PRINTER) ;
        #~ close (DATA) }
   system("lpr -S $PrinterPath -P $PrinterPort $_.ps") ;
   if ($remove)
     { unlink $filename } }


Hans



More information about the pdftex mailing list