home *** CD-ROM | disk | FTP | other *** search
/ Mega Top 1 / os2_top1.zip / os2_top1 / APPS / TEKST / PSUTILS / FIXDLSRP.CMD < prev    next >
OS/2 REXX Batch file  |  1994-01-14  |  1KB  |  50 lines

  1. extproc perl -Sx 
  2. #!perl
  3. # fixdlsrps: fix DviLaser/PS document to work with PSUtils
  4.  
  5. # feed this into perl
  6. eval 'exec perl -S $0 "$@"'
  7.    if $running_under_some_shell;
  8.  
  9. $nesting = 0;
  10. $page = 1;
  11. $infont = 0;
  12.  
  13. @fonts = ();
  14.  
  15. while (<>) {
  16.    if (/^XP/) {
  17.       print $_;
  18.       $infont++;
  19.       push(@fonts, $_);
  20.       $infont-- if /PXL.*RP/;
  21.    } elsif ($infont) {
  22.       print $_;
  23.       push(@fonts, $_);
  24.       $infont-- if /PXL.*RP/;
  25.    } elsif (/^%%EndProlog/ && !$nesting) {
  26.       print "\$DviLaser begin/GlobalMode{}bdef/LocalMode{}bdef\
  27. /RES{/Resolution xdef/PxlResolution xdef\
  28.   /RasterScaleFactor PxlResolution Resolution div def\
  29.   InitialMatrix setmatrix 72.0 Resolution div dup scale}bdef\
  30. /DoInitialScaling{}bdef end\n";
  31.       print "\$DviLaser begin /XP {} def /RP {} def end\n";
  32.       print $_;
  33.    } elsif (/^%%BeginPageSetup/ && !$nesting) {
  34.       print "%%Page: $page $page\n";
  35.       $page++;
  36.       print $_;
  37.    } elsif (/^%%EndPageSetup/ && !$nesting) {
  38.       print @fonts;
  39.       print $_;
  40.    } elsif (/^%%BeginDocument/ || /^%%BeginBinary/) {
  41.       print $_;
  42.       $nesting++;
  43.    } elsif (/^%%EndDocument/ || /^%%EndBinary/) {
  44.       print $_;
  45.       $nesting--;
  46.    } elsif (!/^%%PageBoundingBox:/) {
  47.       print $_;
  48.    }
  49. }
  50.