Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Check21/X9.37 text extractor

by Anonymous Monk
on Jun 16, 2015 at 20:08 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1130701]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (7)
As of 2024-04-23 14:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found