473,748 Members | 10,539 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Zlib to uncompress pdf file

296 Contributor
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 5761
KevinADC
4,059 Recognized Expert Specialist
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 Recognized Expert Moderator Specialist
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
1387
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 getString(s): s = base64.decodestring(s) s = zlib.decompress(s, -15) return s
2
8709
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 gives errors sometimes such as "Object reference not set to an instance of an object". I think it has something to do with zlib needing the pointers to my variables, and I can't figure out how to give it the pointer to a byte array. In the C++...
6
17146
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 stating it's not a valid Com component. I'm new to vb.net so any help would be appreciated. Thanks. -- Dennis in Houston
1
7942
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 (Object reference not set to an instance of an object) when I try to call the dll's compress function. The function in the dll is declared as such: int compress (Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen) I've...
2
2247
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
2876
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). Heres a little prog that demonstrates the problem: //include zlib header etc int main(int argc, char * argv) {
5
4814
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 output must match exactly compression generated with the c++ zlib.org code with default compression. zlib.org c# code is as slow as hell! Not sure if I'm doing anything
4
2930
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 I`ve put such line --with-zlib=/home/domena_nazwa/domains/test.com/public_html/gallery/lib/zziplib.lib
2
6390
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
8991
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8831
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9548
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9374
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8244
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6796
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
3315
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2787
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2215
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.