Article View: comp.text.tex
Article #630Re: Dvi to PS with double-sided printing
From: Bennett E. Todd
Date: Fri, 31 Jul 1992 00:53
Date: Fri, 31 Jul 1992 00:53
78 lines
3385 bytes
3385 bytes
In article <1992Jul28.155324.12191@tamsun.tamu.edu> t0e0078@tamsun.tamu.edu (Terje Eggestad) writes:
>>In article <1992Jul23.121433.23083@itnsg1.cineca.it>, lele@itnsg1.cineca.it (Lele Gaifax) writes:
>>|> Is there any dvi2ps that let me print all the odd sides first, and the all
>>|> the even sides?
>I don't think so, dvi2ps do not completely conform with the PS structure
>convention, at least so can't ghostscript make out where pages ends and begins.
I use dvitps with the ``-C'' option, and that generates conforming
PostScript. I use the following Perl to whack it into even and odd files. I
also use the ``up'' package, with a command line ``parr -s|up -n pup'' to
generate two-up pages in signature order, so I can just drive a staple
through the center (with a deep-throat stapler) and have a little pamphlet.
Here's my ``psdeal'' program.
-Bennett
bet@sbi.com
#!/usr/local/bin/perl
# Take a conforming PostScript program as input, and deal the pages out
# into two piles, "odd.ps" and "even.ps". Each gets a modified copy of
# the prologue, and a modified copy of the trailer. The modifications
# reflect the changes in the %%Pages: comment -- any found in the
# prologue (or indeed anywhere in the file) is deleted, and one reading
# "%%Pages: (atend)" is inserted right after the leading "%!PS-Adobe"
# line. The trailer has a "%%Pages: nn" line inserted. The page-dividing
# "%%Page: " comments have their parameters ignored, and are replaced
# with "%%Page: ? nn" suitably numbered in each file.
#
# The prologue is defined to be everything down to (but not including)
# the first "%%Page: " line. The pages begin with "%%Page: " and continue
# until either the next "%%Page: " line or the "%%Trailer" line; and the
# trailer is defined to be everything from the "%%Trailer" line to the
# end of the file.
open(ODD, ">odd.ps" ) || die "cannot open odd.ps, stopped";
open(EVEN, ">even.ps") || die "cannot open even.ps, stopped";
# Gobble prologue, frobbing %%Pages as described above
$_=<>;
/^%!PS-Adobe/ || die "Input is not Conforming PostScript, stopped";
print ODD;
print EVEN;
print ODD "%%Pages: (atend)\n";
print EVEN "%%Pages: (atend)\n";
while (($_ = <>) !~ /^%%Page: /) {
print ODD && print EVEN unless /^%%Pages: /;
}
# Now suck in pages, dealing them out to ODD and EVEN -- starting with odd
# However, note that we are coming in with a %%Page line in the buffer, so
# it will immediately switch buffers
$opage = 0;
$epage = 0;
$odd = 0;
while (! /^%%Trailer$/) {
if (/^%%Page: /) {
$odd = ! $odd;
$_ = "%%Page: ? " . ($odd ? ++$opage : ++$epage) . "\n";
}
if ($odd) {
print ODD;
} else {
print EVEN;
}
$_ = <>;
}
# Finally copy the trailer to both files
do {
print ODD && print EVEN unless /^%%Pages:/;
} while (<>);
print ODD "%%Pages: $opage\n";
print EVEN "%%Pages: $epage\n";
close ODD;
close EVEN;
Technical Details
Message-ID:
<701@cyclone.sbi.com>Path:
arc1-ca.pugleaf.net!sparky!uunet!psinntp!internet!sbi!zeuswtc!cyclone!betReferences:
<1992Jul23.121433.23083@itnsg1.cineca.it> <1992Jul28.130707.45489@infoserver.th-darmstadt.de> <1992Jul28.155324.12191@tamsun.tamu.edu>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!psinntp!internet!sbi!zeuswtc!cyclone!bet From: bet@cyclone.sbi.com (Bennett E. Todd) Newsgroups: comp.text.tex Subject: Re: Dvi to PS with double-sided printing Message-ID: <701@cyclone.sbi.com> Date: 31 Jul 92 00:53:52 GMT References: <1992Jul23.121433.23083@itnsg1.cineca.it> <1992Jul28.130707.45489@infoserver.th-darmstadt.de> <1992Jul28.155324.12191@tamsun.tamu.edu> Organization: Salomon Brothers, Inc Lines: 78