home *** CD-ROM | disk | FTP | other *** search
/ jppd.dyndns.org / jppd.dyndns.org.tar / jppd.dyndns.org / QUERYPRO / Impressora_PDF / converter.exe / GPLGS / gsnup.ps < prev    next >
Text File  |  2002-02-22  |  3KB  |  89 lines

  1. %!
  2. %    Copyright (C) 1999 Aladdin Enterprises.  All rights reserved.
  3. % This software is provided AS-IS with no warranty, either express or
  4. % implied.
  5. % This software is distributed under license and may not be copied,
  6. % modified or distributed except as expressly authorized under the terms
  7. % of the license contained in the file LICENSE in this distribution.
  8. % For more information about licensing, please refer to
  9. % http://www.ghostscript.com/licensing/. For information on
  10. % commercial licensing, go to http://www.artifex.com/licensing/ or
  11. % contact Artifex Software, Inc., 101 Lucas Valley Road #110,
  12. % San Rafael, CA  94903, U.S.A., +1(415)492-9861.
  13.  
  14. % $Id: gsnup.ps,v 1.4 2002/02/21 21:49:28 giles Exp $
  15. % Prefix this to very well-behaved PostScript files for n-up printing.
  16.  
  17. /cdef { 1 index where { pop pop } { def } ifelse } def
  18.  
  19. %%%%%%%%%%%%%%%% Begin parameters %%%%%%%%%%%%%%%%
  20.  
  21. % All parameters are also settable from the command line with -d, e.g.,
  22. % -d.Nx=3
  23.  
  24. /.Nx 2 cdef            % # of pages across the physical page
  25. /.Ny 2 cdef            % # of pages down the physical page
  26. /.Landscape false cdef        % if true, rotate page by 90 degrees
  27.  
  28. %%%%%%%%%%%%%%%% End parameters %%%%%%%%%%%%%%%%
  29.  
  30. vmstatus pop pop 0 eq { save pop } if
  31. .Landscape {
  32.   currentpagedevice /PageSize get aload pop
  33.   exch 2 array astore
  34.   1 dict dup /PageSize 4 -1 roll put
  35.   setpagedevice
  36. } if
  37. /.BP currentpagedevice /BeginPage get def
  38. /.EP currentpagedevice /EndPage get def
  39. /.Ps 1 string def    % survive save/restore
  40. /.Pn { .Ps 0 get } def
  41. true setglobal        % protect from restore
  42. /.ELevel [0] def
  43. /.Rmat matrix def
  44. false setglobal
  45. /.max { 2 copy lt { exch } if pop } cdef
  46. % Work around the common save ... showpage ... restore locution.
  47. /restore {
  48.   .Rmat currentmatrix pop restore
  49.   vmstatus pop pop .ELevel 0 get lt { .Rmat setmatrix } if
  50. } bind def
  51. <<
  52.   /BeginPage {
  53.     .BP .Nx .Ny .max
  54.     gsave
  55.       initclip clippath pathbbox exch 4 -1 roll sub 3 1 roll exch sub
  56.     grestore
  57.     2 copy exch .Nx div exch .Ny div
  58.     .Pn dup .Nx mod exch .Nx idiv .Ny 1 sub exch sub
  59.         % Stack: nmax pw ph pw/nx ph/ny ix iy
  60.     exch 3 index mul exch 2 index mul
  61.     translate
  62.         % Stack: nmax pw ph pw/nx ph/ny
  63.     4 -1 roll 4 index div 4 -1 roll 4 index div
  64.         % Stack: nmax pw/nx ph/ny pw/nmax ph/nmax
  65.     exch 4 -1 roll exch sub 2 div
  66.     3 1 roll sub 2 div
  67.     translate
  68.         % Stack: nmax
  69.     1 exch div dup scale
  70.   }
  71.   /EndPage {
  72.     .ELevel 0 vmstatus pop pop put
  73.     .Ps 0 .Pn 1 add .Nx .Ny mul mod put    
  74.     .Pn 0 eq {
  75.       .EP
  76.     } {
  77.       pop pop false
  78.     } ifelse
  79.   }
  80. >> setpagedevice
  81. /.EOJ {
  82.   { .Pn 0 eq { exit } if showpage } loop
  83. } def
  84.  
  85. { currentfile cvx exec .EOJ } exec
  86.