Ignore:
Timestamp:
2001-06-20T16:52:39+12:00 (23 years ago)
Author:
jrm21
Message:

when extracting text from postscript, we now wrap the lines, so that a
large paragraph doesn't keep going east.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl/bin/script/gsConvert.pl

    r2574 r2600  
    399399    }
    400400
    401     # this will probably give a warning under windows...
    402     &util::rm("$output_filestem.err");
     401    &util::rm("$output_filestem.err") if (-e "$output_filestem.err");
    403402
    404403    # Was the conversion successful?
     
    506505    $cmd .= " 2> $output_filestem.err";
    507506    $!=0;
     507
    508508    my $retcode=system($cmd);
    509509    $retcode = $? >> 8;  # see man perlfunc - system for this...
     
    610610    close OUT;
    611611    }
     612    # wrap the text - use a minimum length. ie, first space after this length.
     613    my $wrap_length=72;
     614    &util::mv("$output_filestem.text", "$output_filestem.text.tmp");
     615    open INFILE, "$output_filestem.text.tmp" ||
     616    die "Couldn't open file: $!";
     617    open OUTFILE, ">$output_filestem.text" ||
     618    die "Couldn't open file for writing: $!";
     619    my $line="";
     620    while ($line=<INFILE>) {
     621    while (length($line)>0) {
     622        if (length($line)>$wrap_length) {
     623        $line =~ s/^(.{$wrap_length}[^\s]*)\s*//;
     624        print OUTFILE "$1\n";
     625        } else {
     626        print OUTFILE "$line";
     627        $line="";
     628        }
     629    }
     630    }
     631    close INFILE;
     632    close OUTFILE;
     633    &util::rm("$output_filestem.text.tmp");
     634
    612635    &util::rm("$output_filestem.err") if (-e "$output_filestem.err");
    613636    return 1;
Note: See TracChangeset for help on using the changeset viewer.