By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,693 Members | 1,972 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,693 IT Pros & Developers. It's quick & easy.

Zlib to uncompress pdf file

100+
P: 296
Expand|Select|Wrap|Line Numbers
  1. use strict ;
  2.     use warnings ;
  3.  
  4.     use Compress::Zlib ;
  5.  
  6.     my $x = inflateInit() or die "Cannot create a inflation stream\n" ;
  7.  
  8.     my $input = '' ;
  9.  
  10.     open(INPUTFILE,"E:\\test.pdf") or die "Can't create the output file : $!";
  11.     open(OUTPUTFILE,'>',"E:\\test1.txt") or die "Can't create the output file : $!";
  12.  
  13.     binmode INPUTFILE;
  14.     binmode OUTPUTFILE;
  15.  
  16.     my ($output, $status) ;
  17.     while (read(INPUTFILE, $input, 4096))
  18.     {
  19.         ($output, $status) = $x->inflate(\$input) ;
  20.  
  21.  
  22.     print OUTPUTFILE $output if $status == Z_OK or $status == Z_STREAM_END ;
  23.  
  24.         last if $status != Z_OK ;
  25.     }
  26.  
  27.     close (INPUTFILE);
  28.     close (OUTPUTFILE);
  29.  
  30.     die "inflation failed\n" unless $status == Z_STREAM_END;

When I print $status "data error" is getting printed.

How to uncompress the pdf file ?
Jul 11 '08 #1
Share this Question
Share on Google+
2 Replies


KevinADC
Expert 2.5K+
P: 4,059
if the pdf file were compressed I would think the extension would be .gz or other file extension that indicates it was compressed, like .zip.
Jul 11 '08 #2

numberwhun
Expert Mod 2.5K+
P: 3,503
If you are interested in playing around with PDF's, you may want to check out how some of the pdf modules on CPAN work.

I agree with Kevin though, pdf is not an extension that denotes compression. Just like a .jpg/.jpeg, the file may have its own type of compression, but the extension is not condusive with it and thus uncompress utilities have not effect.


Regards,

Jeff
Jul 11 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.