home *** CD-ROM | disk | FTP | other *** search
/ Internet Magazine 2002 February / INTERNET88.ISO / pc / software / windows / bits / pdf995 / data1.cab / Program_Executable_Files / res / gsnup.ps < prev    next >
Encoding:
Text File  |  2001-12-08  |  2.9 KB  |  92 lines

  1. %!
  2. %    Copyright (C) 1999 Aladdin Enterprises.  All rights reserved.
  3. % This file is part of GNU Ghostscript.
  4. % GNU Ghostscript is distributed in the hope that it will be useful, but
  5. % WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
  6. % to anyone for the consequences of using it or for whether it serves any
  7. % particular purpose or works at all, unless he says so in writing.  Refer
  8. % to the GNU General Public License for full details.
  9. % Everyone is granted permission to copy, modify and redistribute GNU
  10. % Ghostscript, but only under the conditions described in the GNU General
  11. % Public License.  A copy of this license is supposed to have been given
  12. % to you along with GNU Ghostscript so you can know your rights and
  13. % responsibilities.  It should be in a file named COPYING.  Among other
  14. % things, the copyright notice and this notice must be preserved on all
  15. % copies.
  16.  
  17. % $RCSfile: gsnup.ps,v $ $Revision: 1.2.2.1 $
  18. % Prefix this to very well-behaved PostScript files for n-up printing.
  19.  
  20. /cdef { 1 index where { pop pop } { def } ifelse } def
  21.  
  22. %%%%%%%%%%%%%%%% Begin parameters %%%%%%%%%%%%%%%%
  23.  
  24. % All parameters are also settable from the command line with -d, e.g.,
  25. % -d.Nx=3
  26.  
  27. /.Nx 2 cdef            % # of pages across the physical page
  28. /.Ny 2 cdef            % # of pages down the physical page
  29. /.Landscape false cdef        % if true, rotate page by 90 degrees
  30.  
  31. %%%%%%%%%%%%%%%% End parameters %%%%%%%%%%%%%%%%
  32.  
  33. vmstatus pop pop 0 eq { save pop } if
  34. .Landscape {
  35.   currentpagedevice /PageSize get aload pop
  36.   exch 2 array astore
  37.   1 dict dup /PageSize 4 -1 roll put
  38.   setpagedevice
  39. } if
  40. /.BP currentpagedevice /BeginPage get def
  41. /.EP currentpagedevice /EndPage get def
  42. /.Ps 1 string def    % survive save/restore
  43. /.Pn { .Ps 0 get } def
  44. true setglobal        % protect from restore
  45. /.ELevel [0] def
  46. /.Rmat matrix def
  47. false setglobal
  48. /.max { 2 copy lt { exch } if pop } cdef
  49. % Work around the common save ... showpage ... restore locution.
  50. /restore {
  51.   .Rmat currentmatrix pop restore
  52.   vmstatus pop pop .ELevel 0 get lt { .Rmat setmatrix } if
  53. } bind def
  54. <<
  55.   /BeginPage {
  56.     .BP .Nx .Ny .max
  57.     gsave
  58.       initclip clippath pathbbox exch 4 -1 roll sub 3 1 roll exch sub
  59.     grestore
  60.     2 copy exch .Nx div exch .Ny div
  61.     .Pn dup .Nx mod exch .Nx idiv .Ny 1 sub exch sub
  62.         % Stack: nmax pw ph pw/nx ph/ny ix iy
  63.     exch 3 index mul exch 2 index mul
  64.     translate
  65.         % Stack: nmax pw ph pw/nx ph/ny
  66.     4 -1 roll 4 index div 4 -1 roll 4 index div
  67.         % Stack: nmax pw/nx ph/ny pw/nmax ph/nmax
  68.     exch 4 -1 roll exch sub 2 div
  69.     3 1 roll sub 2 div
  70.     translate
  71.         % Stack: nmax
  72.     1 exch div dup scale
  73.   }
  74.   /EndPage {
  75.     .ELevel 0 vmstatus pop pop put
  76.     .Ps 0 .Pn 1 add .Nx .Ny mul mod put    
  77.     .Pn 0 eq {
  78.       .EP
  79.     } {
  80.       pop pop false
  81.     } ifelse
  82.   }
  83. >> setpagedevice
  84. /.EOJ {
  85.   { .Pn 0 eq { exit } if showpage } loop
  86. } def
  87.  
  88. { currentfile cvx exec .EOJ } exec
  89.