psnup -- print multiple page images to one physical page 
Author Message
 psnup -- print multiple page images to one physical page

  I have just completed writing a version of psnup which will run on
  any Unix platform with perl and any MS-DOS platform with or without
  perl.

Why write _another_ version of psnup?

  The program was written out of a need for a cheaper way of drafting
  TeX and{*filter*}documents, when one only has access to a text screen
  and a printer that one must pay for.  There are of course a number of
  utilities that already do this sort of thing, but all the ones I came
  across had a bad habit of being upset by dvips' use of paging
  commands, which tended to{*filter*}the output up quite a bit, or they
  required that the postscript conformed to the Adobe Documentation
  Standards, which was a pain, since I was also tinkering with writing
  PostScript code as well.

  A lot of their problems stemmed from the fact that the dvips output
  called the page size operators letter. legal, or note, which meant
  that having set up their environment, the dvips code unlatched it all
  as soon as it got to the interpreter, by executing one of these
  commands.  The end result was that the first page was invariably full
  size, and every page after that was placed over the image, at the
  reduced scale, and translated to the correct spot on the page.

  Then there were also the programs which will print text on a
  PostScript printer, such as a2ps.  There were problems with these as
  well: most of them understood backspaces, tabbing, etc etc, but they
  did not do overstrike at all, which I find makes reading man pages
  much more difficult.  So I thought I'd make my package capable of
  handling ASCII text too.  Essentially psnup is completely seperate
  from the line printer routine -- psnup calls it when it detects an
  ASCII file, and it runs just like any other PostScript program psnup
  deals with, thus making things really nice and neat.

OK, what's so special about yours?

  psnup has the advantages that it will accept and print any number of
  files and produce pages with any number of images to a page.  psnup
  will accept ASCII text as well as PostScript, and is smart enough to
  work out what each file contains.  There are a large number of
  options, including the ability for margins to be flipped on alternate
  pages (so that when double-sided, one side may be bound).  This
  margin flip also flips page numbers so that they appear on the
  outside corners of the output.

  Files to be presented to psnup do not have to obey the Adobe
  Documentation Standard, which is a problem I've had with some other
  versions of psnup (the psutils one in particular).  psnup also has
  advantages over most implementations of a2ps as it can take in any
  number of files at once.  Of course it's major advantage is that you
  can mix text and PostScript files as you like.

  The PostScript part of it has been made to be as watertight as
  possible and to appear totally transparent to input programs.  Thus
  an input program may execute any and all graphics operators freely
  because psnup has either redefined them to do things in a safe way,
  or they are redefined to be nothing.

  The line printer routine is capable of backspaces, form feeds, tabs,
  line feed, carriage returns and most importantly, overstrike.

  The code is in two main parts.  The body of the psnup code was
  written in PostScript, and then packaged in a Perl shell script, to
  handle file manipulations, command line options and parameter passing
  to the main part of the code.

  Currently, the PostScript portion of psnup is known to run on the
  HPIIIsi, QMS2000, Ghostscript 2.6.1 and Apple's LaserWriter NT.  The
  Perl script has been found to run under Unix system V, and under
  MS-DOS.  I assume it would run under any installation of Perl around,
  since Perl is pretty standard.  As this is a first release, it has
  not been tested on as wide a set of platforms as I would like, and
  any reports of it running elsewhere would be gratefully received.

Where to get it. Either take this posting to comp.sources.postscript, or:

  psnup can be anonymously ftped from ftp.cs.rmit.edu.au as
  /pub/utils/psnup22.tar.gz, along with a README file.

--
============================================================================
Malcolm Herbert                                      BComp (Dig Tech) 2nd yr

============================================================================



Sun, 01 Dec 1996 10:15:58 GMT  
 psnup -- print multiple page images to one physical page
OK, here are a few followup notes to the release of psnup22 outlined
earlier:

- I should have remembered that this is a newsgroup for PostScript and
  not everyone knows about perl, or where to get it, and for this I
  apologise.  Probably the best place to look would be comp.sources.perl
  or comp.lang.perl.  I would have put the ftp sites of places that have
  it, but archie.au seems momentarily offline for some reason.

- in one of my more hasty changes to the code, $Date ended up being
  chopped twice, leaving the year (most likely) as 199  This can simply be
  fixed by deleting the extra chop command, after the second instance of
  $Date.

- Some dvips output seems to make psnup pile the page images up into the
  first spot on the page.  This is due to dvips saving the graphics
  state, emitting a showpage, and then restoring it again.  Normally not
  a problem, but since psnup does translation of the user coordinate
  system, these changes get lost when the dvips code gets hold of the
  interpreter again ...

  I had thought of this, but decided not to implement the code, as
  mucking around with the graphics stack I don't find particularly
  kosher.  I will however take another look, and see what can be done
  about it.  (the main problem is that the dvips code also does a save
  and restore in there as well, which is supposed to also save and
  restore the contents of the graphics stack, according to the Red Book.)

- psnup will have a problem with EPS output because it does not contain
  an instance of the showpage operator at the end of pages, so images
  will again pile up on themselves with abandon.  At the moment the only
  thing I can suggest is to add in a showpage command at the end of
  every page image.

  btw: is there any way of detecting whether or not paint has been
  placed on the page?  If there is, it would be simply a matter of
  detecting this at the beginning of pstxt (which is the code that works
  out whether to execute or print the next file in).

Thanks to those of you kind enough to point these out ... unfortunately
I don't think I'll be able to fix any of them until after my exams,
which finish at the end of next week.  (This is the reason I released it
when I did ... stopped me fiddling with it ... :)

--
============================================================================
Malcolm Herbert                                      BComp (Dig Tech) 2nd yr

============================================================================



Mon, 02 Dec 1996 09:35:58 GMT  
 psnup -- print multiple page images to one physical page

     I have just completed writing a version of psnup which will run on
     any Unix platform with perl and any MS-DOS platform with or without
     perl.

   Why write _another_ version of psnup?

Aargh! There are already a plethora of psnups, can you *please* call it
something else? (BTW, my version of psnup also runs on MSDOS, NT, OS/2, Unix,
VMS, etc...)

a.
--
Angus Duggan, Harlequin Ltd., Barrington Hall   | PSUtils is available from
Barrington, Cambridge CB2 5RG, U.K.             | ftp.dcs.ed.ac.uk in pub/ajcd.



Tue, 03 Dec 1996 21:16:12 GMT  
 psnup -- print multiple page images to one physical page

   OK, here are a few followup notes to the release of psnup22 outlined
   earlier:

   - Some dvips output seems to make psnup pile the page images up into the
     first spot on the page.  This is due to dvips saving the graphics
     state, emitting a showpage, and then restoring it again.  Normally not
     a problem, but since psnup does translation of the user coordinate
     system, these changes get lost when the dvips code gets hold of the
     interpreter again ...

     I had thought of this, but decided not to implement the code, as
     mucking around with the graphics stack I don't find particularly
     kosher.  I will however take another look, and see what can be done
     about it.  (the main problem is that the dvips code also does a save
     and restore in there as well, which is supposed to also save and
     restore the contents of the graphics stack, according to the Red Book.)

If you want to make your version of psnup more general, you'll have to muck
around with the graphics state, because many applications alter their
coordinate system to wierd and wonderful things. My psnup (from PSUtils) looks
at the CTM before and after the document setup, and calculates the
transformation which got it into document coordinate system. It then applies
this transformation to each page, after the shifting, scaling and rotating
which happens in the normal user space.

     btw: is there any way of detecting whether or not paint has been
     placed on the page?  If there is, it would be simply a matter of
     detecting this at the beginning of pstxt (which is the code that works
     out whether to execute or print the next file in).

No, there isn't. In Level 2, you can use the BeginPage and EndPage procedures
to detect when showpages are executed, and when the job ends so that you can
flush remaining pages, but there's no equivalent Level 1 mechanism.

(And *please* can you release the next version under another name, to prevent
confusion?)

a.
--
Angus Duggan, Harlequin Ltd., Barrington Hall   | PSUtils is available from
Barrington, Cambridge CB2 5RG, U.K.             | ftp.dcs.ed.ac.uk in pub/ajcd.



Wed, 04 Dec 1996 19:47:18 GMT  
 psnup -- print multiple page images to one physical page

Quote:

>If you want to make your version of psnup more general, you'll have to muck
>around with the graphics state, because many applications alter their
>coordinate system to wierd and wonderful things. My psnup (from PSUtils) looks
>at the CTM before and after the document setup, and calculates the
>transformation which got it into document coordinate system. It then applies
>this transformation to each page, after the shifting, scaling and rotating
>which happens in the normal user space.

Hmmm ... sounds really simple ... so I'd guess you'd pop the graphics
stack, reverse engineer the transformation on the ctm from what you know
it was originally, set the ctm back to your original one, perform the
shifting/translation/scaling as necessary to get the next image in
place, then transform the ctm back to what the document wants, and
resave the graphics stack ... neat.

[ about EPS failing to print, and question on painting flag ]

Quote:
>No, there isn't. In Level 2, you can use the BeginPage and EndPage procedures
>to detect when showpages are executed, and when the job ends so that you can
>flush remaining pages, but there's no equivalent Level 1 mechanism.

yeh ... that's what everyone else has been telling me, although I have
had an interesting solution from Kevin Grover (btw: I didn't seem to be
able to mail you back directly, but thanks anyway!), which was to
temporarily redefine the showpage operator to null, run the EPS file, and
explicitly execute a showpage immediately after it.  This would mean
that EPS files with no showpage are printed properly, and those with one
in it already do not produce an extra page after themselves ...

--
============================================================================
Malcolm Herbert                                      BComp (Dig Tech) 2nd yr

============================================================================



Thu, 05 Dec 1996 18:14:01 GMT  
 psnup -- print multiple page images to one physical page

        ...

Quote:
>>No, there isn't. In Level 2, you can use the BeginPage and EndPage procedures
>>to detect when showpages are executed, and when the job ends so that you can
>>flush remaining pages, but there's no equivalent Level 1 mechanism.
>yeh ... that's what everyone else has been telling me, although I have
>had an interesting solution from Kevin Grover (btw: I didn't seem to be
>able to mail you back directly, but thanks anyway!), which was to
>temporarily redefine the showpage operator to null, run the EPS file, and
>explicitly execute a showpage immediately after it.  This would mean
>that EPS files with no showpage are printed properly, and those with one
>in it already do not produce an extra page after themselves ...
>Malcolm Herbert                                      BComp (Dig Tech) 2nd yr


I happen to believe that one should not have showpage commands in EPS; but, the
EPS standards as stated by Adobe specifically permit showpages to be present.

I suggest that a reading of H.2 Guidlines for Creating EPS Files and H.3
Guidlines for Importing EPS files in PostScript Language Reference, Second
Edition, Adobe Systems Incorporated, Prentice-Hall, 1990, ISBN 0-201-18127-4,
about US$30, is in order.

On the part of the encapsulating application:

        A. A save and restore pair needs to be placed around the EPS
           and the conditioning for the EPS file.

        B. The showpage command needs to be nullified.  E.g.:

                /showpage {} def

        C. The graphics state needs to be set to a standard condition:

                0 setgray
                0 setlinecap
                1 setlinewidth
                0 setlinejoin
                10 setmiterlimit
                [] 0 setdash
                newpath
                /languagelevel where {pop languagelevel 2 eq
                        {false setoverprint
                         false setstrokeadjust} if } if

        D. The stack should be cleared.  The dictionary stack should be
           protected.  The user dictionary should put on the top of the
           dictionary stack

                2 dict begin
                count array astore /Stack exch def
                /Dict_Count countdictstack def
                userdict begin

                        ... the EPS file

                end
                Dict_Count countdictstack ne {rangecheck} if
                Stack aload pop
                end


(Speaking for myself and not for US, US DOE, FNAL nor URA.)
(Product, trade, or service marks herein belong to their respective owners.)



Mon, 09 Dec 1996 04:52:47 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. Help: Printing one logical page to multiple physical pages

2. Printing one page over multiple pages (inverse psnup)

3. printing multiple ps files on one physical page.

4. Printing multiple pages to 1 physical page

5. print multipl pages on one physical page...

6. Multiple instances of graphic on one physical page

7. how to print multiple pages on one page

8. Printing Multiple Pages on One Page

9. Printing multiple pages from one page

10. 4 logical pages on one physical page????

11. psnup -- n-up printing on one page ...

12. psnup -- n-up printing on one page

 

 
Powered by phpBB® Forum Software