groff
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Groff] "creep" and booklets


From: Ted Harding
Subject: Re: [Groff] "creep" and booklets
Date: Fri, 04 Nov 2005 12:21:17 -0000 (GMT)

On 04-Nov-05 Bob Diertens wrote:
> On Fri, Nov 04, 2005 at 12:01:12AM -0000, Ted Harding wrote:
>> Hi Folks,
>> 
>> I'd welcome views and contributions about the following.
>> 
>> It concerns making a "booklet" out of a PS document.
>> 
>> 1. Background:
>> If you have (say) a 16-page PS document, you can run it
>> through the following pipelikne:
>> 
>>   cat doc.ps | psbook | psnup -2 > doclet.ps
>> 
>> [ ... ]
> 
> You can easily do this by manipulating the PostScript file.
> The Perl script below suffices.
> 
> usage:
>    cat doc.ps | psbook | creep 0.5 | psnup -2 > doclet.ps
> 
> Hope this helps,
>     Bob

Excellent idea! And thanks for the snappy response. This would
take the problem out of groff which would be a good thing for
this application (especially since the amount of creep required
=depends on the thickness of paper you are printing to, and I'm
much happier not to have to plant that in the groff source).

I take it, from the look of things, that $creep_incr is in points?

I don't tangle with perl as a rule, but this provides a motive!
(Though it looks as though it would translate well to awk, so
that may keep me happy for a bit).

I'll need to test this a bit on groff output (and other PS
documents). One thing I'm wondering about is whether it would
be wise, for general use, to encapsulate the page in

  gsave <creep> 0 translate [rest of page] grestore

For instance, I just tried it on a PS file (not from groff)
and it did not work. The reason seems to be that each page
begins like:

  %%Page: 1 1
  0 0 translate
  %%BeginPageSetup

etc., which would undo your creep! I think the trigger for inserting
the "grestore" would normally be the occurrence of "showpage", but
this may get wrapped into a definition (as it does in groff, where
"EP" is used, defined as

  /EP{
  level0 restore
  showpage
  }bind def

However, on trials so far the script does seem to work as it stands
on PS files produced by groff. Groff's PS output also defines a "BP"
to initiate the page, which does not include a "translate" command
of its own, so there should not be a need for "gsave ... grestore".

Thanks!
Ted.


> ---begin creep---
>#!/usr/bin/perl
>#
># Enjoy: Bob Diertens, 11/04/2005
> 
> if ($#ARGV != 0) {
>     die "usage: $0 <creep>\n";
> }
> $creep_incr = shift;
> 
> $pagecount = 0;
> $creep = 0;
> 
> while (<>) {
>     print;
>     if (/^%%Page:/) {
>       if ($pagecount % 2) {
>           print "-$creep 0 translate\n";
>       } else {
>           print "$creep 0 translate\n";
>       }
>       $pagecount ++;
>       if ($pagecount %4 == 0) {
>           $creep += $creep_incr;
>       }
>     }
> }
> ---end creep---
> 
> 
> _______________________________________________
> Groff mailing list
> address@hidden
> http://lists.gnu.org/mailman/listinfo/groff

--------------------------------------------------------------------
E-Mail: (Ted Harding) <address@hidden>
Fax-to-email: +44 (0)870 094 0861
Date: 04-Nov-05                                       Time: 12:21:13
------------------------------ XFMail ------------------------------




reply via email to

[Prev in Thread] Current Thread [Next in Thread]