473,320 Members | 1,947 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Zlib to uncompress pdf file

296 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
2 5719
KevinADC
4,059 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
3,509 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

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

Similar topics

0
by: Greg Bakken | last post by:
I am writing a python program that recieves 'compressed and encoded' strings from another piece of software. I can successfully uncompress and decode the strings via import base64, zlib def...
2
by: Bien | last post by:
Would someone mind helping me with a DllImport call to zlib 1.2.1? I've tried several alternatives such as SharpZipLib, but they won't work for what I'm doing. I have it sort of figured out, but it...
6
by: Dennis | last post by:
I am trying to use ZLIB.Dll in a VB.Net project but keep getting an error message that says it can't load the DLL. I tried to add a reference using "Project-Add Reference" but get the error message...
1
by: Dennis Powell | last post by:
Does anyone have a successful implementaion of the zlib.dll in VB. Net they can show me. I'm writting a class encaplsulating zlib functionality and I keep getting a System.NullReferenceException...
2
by: giuseppe.cannella | last post by:
i need to read a row on a gzipped file like the fgets function does on a text file can you help me to find this function thank
4
by: Anonymous | last post by:
Slightly OT, but can't find a zlib specific ng - so hopefuly, someone can point out why uncompressed strings are not matching the original strings (lots of strange characters at end of string). ...
5
by: tombrogan3 | last post by:
Hi, I need to implement in-memory zlib compression in c# to replace an old c++ app. Pre-requisites.. 1) The performance must be FAST (with source memory sizes from a few k to a meg). 2) The...
4
by: MZ | last post by:
Hello! I`ve tried to instal zlib library to use zip functions to pack files into zip archive. I don`t know how I have to configure zlib to make it work. I have built up php.ini file and...
2
by: somsub | last post by:
Hi all, Here is my samle code use strict ; use warnings ; use IO::Uncompress::Unzip ; When I compiled this three lines of code in win32 I got error like below.
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.