467,146 Members | 1,018 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,146 developers. It's quick & easy.

Zlib to uncompress pdf file

100+
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
  • viewed: 5009
Share:
2 Replies
KevinADC
Expert 2GB
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 2GB
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.

Similar topics

reply views Thread by Greg Bakken | last post: by
2 posts views Thread by Bien | last post: by
1 post views Thread by Dennis Powell | last post: by
2 posts views Thread by giuseppe.cannella@gmail.com | last post: by
5 posts views Thread by tombrogan3@googlemail.com | last post: by
4 posts views Thread by MZ | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.