home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 21 PDrivers / 21-PDrivers.zip / psnupos2.zip / psnup.cmd < prev    next >
OS/2 REXX Batch file  |  1995-02-26  |  5KB  |  172 lines

  1. /****************************************************************************
  2.  
  3. PSNUP.CMD -- REXX version of psnup
  4. Clark Gaylord
  5. Blacksburg, Va
  6. cgaylord@vt.edu
  7.  
  8. Version 1.1.OS2 -- 25 February 1995
  9.      Fixed help, enabled -? and -h.  
  10.      Allow stdin.
  11. Version 1.0.OS2 -- 29 January 1995
  12.      Initial OS/2 release.
  13.  
  14. *** MAN PAGE ***
  15. NAME
  16.      psnup - print n-up PostScript pages
  17.  
  18. SYNOPSIS
  19.      psnup [-n 2|4|8|16] [-r] [-s #] [-f file] [-o outfile]
  20.  
  21. DESCRIPTION
  22.      psnup takes an arbitrary PostScript file (or standard input)
  23.      and filters it to give n-up printing.
  24.  
  25. OPTIONS
  26.      -n value
  27.           Select the number of page images that will  be  printed
  28.           per sheet of paper. Allowed values are 2, 4, 8, and 16,
  29.           and the default is 2.
  30.  
  31.      -r   Reverse the order in which page images are laid out  on
  32.           the page. By default, page images are printed from left
  33.           to right, top to bottom.  The -r flag prints the  pages
  34.           from  right to left, bottom to top.  This can be useful
  35.           when using psnup with print  spoolers  (such  as  Tran-
  36.           Script)  that automatically reverse the pages being fed
  37.           to the PostScript printer.
  38.  
  39.      -s   Select the spot for the first image to be printed.  The
  40.           range of spots is from 0 to (nup - 1), where nup is the
  41.           number of images per page.  The default is spot 0 (nor-
  42.           mally the top left of the page).
  43.  
  44.      -f   File to be processed.  Filename may not contain spaces.
  45.           Default is stdin.
  46.  
  47.      -o   Output file.  Default is stdout.
  48.  
  49. REQUIREMENTS
  50.      This shell script uses the getopt(1) command, a  version  of
  51.      which   is  in  the  public  domain  and  available  in  the
  52.      comp.sources.unix archives.
  53.  
  54. OS/2 VERSION ALSO REQUIRES
  55.      nup.pro  and  nup.epi  in  current   directory  or   %PSNUP%
  56.      directory
  57.  
  58. SEE ALSO
  59.      enscript(1), postscript(7)
  60.  
  61. AUTHOR
  62.      The OS/2 REXX version is by Clark Gaylord (cgaylord@vt.edu).
  63.      OS/2 version introduced -f and -o options.
  64.  
  65.      psnup is a shell script written by Roy Smith (phri!roy) that
  66.      uses PostScript scripts written by Ned Batchelder at U. Penn
  67.      (ned@UPenn.CSNet).  The manual page was contributed  by  Mic
  68.      Kaczmarczik (mic@emx.utexas.edu).
  69.  
  70. ****************************************************************************/
  71.  
  72. NupDir = Value( 'PSNUP', ,'OS2ENVIRONMENT' )
  73. IF (NupDir = '') THEN
  74.     NupDir = '.'
  75.  
  76. ProName = Stream( NupDir'\nup.pro', 'c', 'query exists' )
  77. EpiName = Stream( NupDir'\nup.epi', 'c', 'query exists' )
  78. IF ((ProName = '') | (EpiName = '')) THEN
  79.     SIGNAL Help
  80.  
  81. NumUp = 2
  82. Reverse = 'false'
  83. Spot = 0
  84. InFile = 'StdIn'
  85. OutFile = 'StdOut'
  86.  
  87. /* Parse args */
  88. PARSE UPPER ARG Args
  89. IF ((Pos('-H', Args) > 0) | (Pos('-?', Args) > 0)) THEN
  90.     SIGNAL Help
  91. IF (Pos('-N', Args) > 0) THEN
  92.     PARSE Value(Args) With '-N' NumUp .
  93. IF (Pos('-R', Args) > 0) THEN
  94.     Reverse = 'true'
  95. IF (Pos('-S', Args) > 0) THEN
  96.     PARSE Value(Args) With '-S' Spot .
  97. IF (Pos('-F', Args) > 0) THEN
  98.     PARSE Value(Args) With '-F' InFile .
  99. IF (Pos('-O', Args) > 0) THEN
  100.     PARSE Value(Args) With '-O' OutFile .
  101.  
  102. CALL Open ProName
  103. CALL Open EpiName
  104. IF (InFile \= 'StdIn') THEN
  105.     CALL Open InFile
  106.  
  107. DO WHILE (Lines(ProName) > 0)
  108.     Line = LineIn( ProName )
  109.     SELECT
  110.         WHEN (Line = '@#@Pages@#@') THEN
  111.             Line = NumUp
  112.         WHEN (Line = '@#@Rev@#@') THEN
  113.             Line = Reverse
  114.         WHEN (Line = '@#@Start@#@') THEN
  115.             Line = Spot
  116.         OTHERWISE
  117.             ;
  118.     END
  119.     CALL LineOut OutFile, Line
  120. END
  121. CALL Stream ProName, 'c', 'close'
  122.  
  123. DO WHILE (Lines(InFile) > 0)
  124.     CALL Lineout Outfile, LineIn(InFile)
  125. END
  126.  
  127. DO WHILE (Lines(EpiName) > 0)
  128.     CALL Lineout Outfile, LineIn(EpiName)
  129. END
  130.  
  131. CALL Close ProName
  132. CALL Close EpiName
  133. CALL Close InFile
  134. CALL Close OutFile
  135.  
  136. EXIT
  137.  
  138. Help:
  139.     CALL LineOut StdErr,,
  140.         'USAGE: psnup [-n 2|4|8|16] [-r] [-s #] [-f file] [-o outfile]'
  141.     CALL LineOut StdErr, ' '
  142.     CALL LineOut StdErr,,
  143.         'Requires: nup.pro and nup.epi in current directory or %PSNUP%' 
  144.     CALL LineOut StdErr, 'directory.'
  145.     CALL LineOut StdErr, ' '
  146.     CALL LineOut StdErr,,
  147.         '       -n #    Number of pages to put on one page (default 2)'
  148.     CALL LineOut StdErr,,
  149.         '       -r      Reverses order'
  150.     CALL LineOut StdErr,,
  151.         '       -s #    Spot number to print first page (default 0)'
  152.     CALL LineOut StdErr, ' '
  153.     EXIT
  154.  
  155. Open:
  156.     PARSE ARG JunkFile
  157.     OpenRet = Stream( JunkFile, 'c', 'open' )
  158.     IF (OpenRet \= 'READY:') THEN DO
  159.         CALL LineOut StdErr, JunkFile 'could not be opened.'
  160.         EXIT
  161.     END
  162.     RETURN 
  163.  
  164. Close:
  165.     PARSE ARG JunkFile
  166.     CloseRet = Stream( JunkFile, 'c', 'close' )
  167.     IF ((CloseRet \= 'READY:') & (CloseRet \= '')) THEN DO
  168.         CALL LineOut StdErr, JunkFile 'could not be closed.'
  169.         EXIT
  170.     END
  171.     RETURN
  172.