home *** CD-ROM | disk | FTP | other *** search
/ Mega Top 1 / os2_top1.zip / os2_top1 / APPS / TEKST / PSUTILS / FIXDLSRP.PL < prev    next >
Perl Script  |  1993-11-19  |  1KB  |  49 lines

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