http://qs321.pair.com?node_id=1130701


in reply to Check21/X9.37 text extractor

Text part is viewed fine but tiff output cannot be read by any viewer. Paint, Fax reader, MS Image etc. Running on red hat Linux.
#!/usr/bin/perl -w use strict; use Encode; my $tiff_flag = 0; my $count = 0; open(FILE,'<',$ARGV[0]) or die 'Error opening input file'; binmode(FILE) or die 'Error setting binary mode on input file'; while (read (FILE,$_,4)) { my $rec_len = unpack("N",$_); die "Bad record length: $rec_len" unless ($rec_len > 0); read (FILE,$_,$rec_len); if (substr($_,0,2) eq "\xF5\xF2") { if ($tiff_flag) { $count++; open (TIFF, '>', $ARGV[0] . '_img' . sprintf(" +%04d",$count) . '.tiff') or die "Can't create image file"; binmode(TIFF) or die 'Error setting bina +ry mode on image file'; print TIFF substr($_,117); close TIFF; } $_ = substr($_,0,117 +); } print decode ('c +p1047', $_) . "\n"; } close FILE;

Code tags added by GrandFather