Code:
use strict ;
use warnings ;
use Compress::Zlib ;
my $x = inflateInit() or die "Cannot create a inflation stream\n" ;
my $input = '' ;
open(INPUTFILE,"E:\\test.pdf") or die "Can't create the output file : $!";
open(OUTPUTFILE,'>',"E:\\test1.txt") or die "Can't create the output file : $!";
binmode INPUTFILE;
binmode OUTPUTFILE;
my ($output, $status) ;
while (read(INPUTFILE, $input, 4096))
{
($output, $status) = $x->inflate(\$input) ;
print OUTPUTFILE $output if $status == Z_OK or $status == Z_STREAM_END ;
last if $status != Z_OK ;
}
close (INPUTFILE);
close (OUTPUTFILE);
die "inflation failed\n" unless $status == Z_STREAM_END;
When I print $status "data error" is getting printed.
How to uncompress the pdf file ?
Comment