Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi,
Can anyone suggest on Flatedecode .
How can it be made in perl.
I want to use Flatedecode to decompress the pdf files .
Please let me know on my problem.
Thankyou .

Replies are listed 'Best First'.
Re: Perl script for FlateDecode
by Courage (Parson) on Nov 29, 2003 at 17:07 UTC
    ordinary "Compress::Zlib" will do. Below is one of my scripts, also I have a script that reorganizes PDF to become in all uncompressed objects.
    use strict; use Compress::Zlib; open my $fh, '<d:\WORK\Documentation\protect\PSAX1250_IG.pdf'; binmode $fh; binmode STDOUT; undef $/; my @r = <$fh>=~/\/FlateDecode\s+\/Length\s+(\d+).*?stream\r\n(.*?)ends +tream/sg; my $i; for ($i=0;$i<$#r;$i+=2) { my ($l,$s) = ($r[$i],$r[$i+1]); print STDERR "l=$l,".length($s),"\n"; $s = substr($s,0,$l); my ($d,$stat) = inflateInit(); print STDERR "stat=$stat\n"; my ($out); ($out,$stat) = $d->inflate($s); print STDERR "stat=$stat\n"; print STDERR "length(\$out)=",length($out),"\n"; print "$out\n\n\n-------------------\n"; }

    Courage, the Cowardly Dog
    things, I do for love to perl...

Re: Perl script for FlateDecode
by The Mad Hatter (Priest) on Nov 29, 2003 at 15:35 UTC
    A Google search for flatedecode appears to tell me that Flatedecode is used in PNG images and PDFs. Try a CPAN search for PDF for Perl PDF manipulation libraries such as PDF::API2.