[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] Formatted printing using 'rtf' file



>Brian McNett wrote...
>
>I'm rather in the reverse position of needing to READ from an rtf file.

Maybe the following code will get you started.

David Seay

--------------

#!/perl5

  require 'StandardFile.pl';

  $rtfFilePath = StandardFile::GetFile("Select a \'.rtf\' file to open",
$default);
  $fileSize = -s $rtfFilePath;
  open(FILEDATA, "$rtfFilePath" || die "Can't get $rtfFilePath... $^E" );
  read(FILEDATA, $rtfTemplate, $fileSize);
  close(FILEDATA);
  @rtfLines = split(/\n/,$rtfTemplate);
  for $i (0..$#rtfLines) {
      if ($rtfLines[$i] =~ /\\pict/) { next }
      if ($rtfLines[$i] !~ /\\cf1 /) { next }
      ($x,$text) = split(/\\cf1 /,$rtfLines[$i]);
      chop($text);
      chop($text);
      $text =~ s/\\tab/\t/;
      $text =~ s/\\par/\n/;
      print "$text\n";
  }


__END__




# ===== Want to unsubscribe from this list?
# ===== Send mail with body "unsubscribe" to macperl-request@macperl.org