Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Check21/X9.37 text extractor

by Anonymous Monk
on Jun 16, 2015 at 20:08 UTC ( #1130701=note: print w/replies, xml ) Need Help??


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

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1130701]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (6)
As of 2019-11-20 15:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Strict and warnings: which comes first?



    Results (98 votes). Check out past polls.

    Notices?