Article View: comp.text.tex
Article #503Re: Dvi to PS with double-sided printing
From: Ulrich Grepel
Date: Tue, 28 Jul 1992 13:07
Date: Tue, 28 Jul 1992 13:07
80 lines
3570 bytes
3570 bytes
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 saw this feature in the dvi2xx package by Gustaf Neumann
|> and I liked it alot.
|> Otherwise, is there a way to obtaining double-faced pages?
|> thanx a lot,
|> lele.
|> --
|> Lele Gaifax - lele@itnsg1.cineca.it
|> Sicuramente i cattivi hanno scoperto qualche cosa che i buoni ignorano.
|> - Woody Allen
I just was in need of the same thing - printing only every-second-page.
I came out with two awk-scripts that do the neccessary split of the dvips-output.
I dunno if it works with dvi2ps (is it something different?). Here are the
scripts:
------>8----- even.awk -----------------
BEGIN {state = 2; pag = 1;}
/%%Pages: / {$2 = "(atend)"; $3 = "-1"}
/%%Page: / {if ($2 % 2 == 0)
{
state = 0;
$3 = pag++;
}
else
{
if (state)
printf("%%%%Page: 0 %d\nbop eop\n", pag++);
state = 1;
}
}
/%%Trailer/ {state = 0}
/./ {if (state != 1) print}
END {printf("%%%%Pages: %d -1\n", --pag);}
------->8------ end of even.awk, begin of odd.awk -------------
BEGIN {state = 0; pag = 1;}
/%%Pages: / {$2 = "(atend)"; $3 = "-1"}
/%%Page: / {if ($2 % 2 != 0)
{
state = 0;
$3 = pag++;
}
else
{
if (state)
printf("%%%%Page: 1 %d\nbop eop\n", pag++);
state = 1;
}
}
/%%Trailer/ {if (state)
printf("%%%%Page: 1 %d\nbop eop\n", pag++);
state = 0}
/./ {if (state == 0) print}
END {printf("%%%%Pages: %d -1\n", --pag);}
---------->8---------- end of odd.awk
These two awk scripts split the postscript code of dvips and even take care
of inserting blank pages if two even or two odd pages directly follow each other.
You may just print one half, then take all the paper (it is supposed that your
printer places paper such that it is ready-to-read, not last-page-first), turn
the whole batch upside-down and reinsert it for printing the other one. You have
to try a little bit to find out which one has to be printed first if you do not
want to revert the paper stack after all is ready.
Just for beginners:
The awk-scripts can be used the following way:
awk -f even.awk dvipsoutput.ps > dvipsoutput.even.ps
awk -f odd.awk dvipsoutput.ps > dvipsoutput.odd.ps
Do whatever you have to to print the resulting postscript files.
I know that there is something better than these minimal awk-scripts, but it
is a perl-script and I haven't got perl but awk. So I just did something.
Since the awk-scripts are pretty simple, it would be possible to convert them
into C-programs or similar for those who don't have awk either.
Uli
Technical Details
Message-ID:
<1992Jul28.130707.45489@infoserver.th-darmstadt.de>Path:
arc1-ca.pugleaf.net!sparky!uunet!cs.utexas.edu!usc!sol.ctr.columbia.edu!ira.uka.de!math.fu-berlin.de!news.th-darmstadt.de!aida!uliReferences:
<1992Jul23.121433.23083@itnsg1.cineca.it>Show Full Headers
Complete Article Headers
Newsgroups: comp.text.tex Path: arc1-ca.pugleaf.net!sparky!uunet!cs.utexas.edu!usc!sol.ctr.columbia.edu!ira.uka.de!math.fu-berlin.de!news.th-darmstadt.de!aida!uli From: uli@aida.intellektik.informatik.th-darmstadt.de (Ulrich Grepel) Subject: Re: Dvi to PS with double-sided printing Message-ID: <1992Jul28.130707.45489@infoserver.th-darmstadt.de> Sender: uli@aida (Ulrich Grepel) Date: Tue, 28 Jul 1992 13:07:07 GMT References: <1992Jul23.121433.23083@itnsg1.cineca.it> Nntp-Posting-Host: aida.intellektik.informatik.th-darmstadt.de Organization: TH Darmstadt Lines: 80