Subject: | Fix for "decodeOne", to allow "decodeAll" to work |
I was trying to remove filters from all streams and then save uncompressed file:
use strict;
use warnings;
use CAM::PDF;
my $doc = CAM::PDF-> new( 'inlineimage.pdf' );
my $root_node = $doc-> { trailer }{ Root };
$doc-> decodeAll( $root_node );
# $doc-> cleanoutput( 'uncompressed.pdf' );
PDF file is from test suite. This results in large amount of warnings. Uncommenting last line leads to more warnings and dying with "This stream is too complex for me to write... Giving up". Data::Dumping reveals the "StreamData" key was added to all dictionary nodes -- because of auto-vivification in line 5575 of PDF.pm.
Changing line 5568 from
if ($objnode->{type} ne 'dictionary')
to
if ($objnode->{type} ne 'dictionary' or not exists $objnode-> {value}{StreamData})
fixes the problem, script completes without warnings as expected.