Subject: | fix for uninitialized value $param{"Index"} when reading PDF version 1.5 file |
Date: | Wed, 16 Jul 2014 10:45:09 -0700 |
To: | bug-PDF-Reuse [...] rt.cpan.org |
From: | Ken Neighbors <ken [...] nsds.com> |
When I try to create a new PDF file using "prDoc" by extracting a few pages
from an existing PDF version 1.5 file, I get this error message:
Use of uninitialized value $param{"Index"} in pattern match (m//) at
blib/lib/PDF/Reuse.pm (autosplit into
blib/lib/auto/PDF/Reuse/crossrefObj.al) line 4275.
(And a bunch of other error messages.)
I did a search and found out that the "Index" parameter is optional, and
has a default value of "[0 Size]" according to this post:
http://stackoverflow.com/questions/4556288/pdf-cross-reference-streams
So I added a check to the crossrefObj subroutine in Reuse.pm which sets
this parameter to the default value if it is missing.
--- Reuse.pm.orig 2008-07-03 13:06:12.000000000 +0000
+++ Reuse.pm 2014-07-16 17:41:45.618989078 +0000
@@ -4245,6 +4245,9 @@
{ $param{$1} = $2 || ' ';
}
}
+ if (! exists $param{'Index'})
+ { $param{'Index'} = "[0 $param{'Size'}]";
+ }
if ((exists $param{'Root'}) && ($param{'Root'} =~ m'^\s*(\d+)'o))
{ $tempRoot = $1;
}
Now it works, at least on my file. Hope this helps.
Ken