I am trying to tokenize a RTF file while keeping the formatting of the font. I can not seem to figure out RTF::Writer to write to another file Any help would be appreciated Heres my code so far
#!/usr/local/bin/perl -w use strict; use Data::Dumper 'Dumper'; use RTF::Writer; use RTF::Tokenizer; use RTF::Parser; die "usage: $0 input output\n" unless @ARGV == 2; my $infile = shift; my $outfile = shift; open my $fh, "<", $infile; open my $output, ">", $outfile; my $tokenizer = RTF::Tokenizer->new(); $tokenizer->read_file($fh); my $writer = RTF::Writer->new_to_file($output); my ( $token_type, $argument, $parameter ); { # reduce bogus warnings no warnings 'uninitialized'; # get past the header ( $token_type, $argument, $parameter ) = $tokenizer->get_token() +until ($token_type eq 'control' and $argument eq 'pard'); } while ($token_type ne 'eof'){ ( $token_type, $argument, $parameter ) = $tokenizer->get_token(); print "$argument " if $token_type eq 'text'; }
In reply to How to tokenize a RTF file and print it to another file by mdavies23
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |