More info.
I tried to remove the leading whitespace, but now testing on
PDF::Imposition dies with:
String is $VAR1 = "/F7 8 0 R /F14 9 0 R /F27 10 0 R >>\n/ProcSet [ /PDF /Text ]\n>>\n<<\n/Type /Page\n/Contents 15 0 R\n/Resources 13 0 R\n/MediaBox [0 0 595.276 841.89]\n/Parent 12 0 R\n>";
F7 is PDF::API2::Basic::PDF::Objind=HASH(0x3fd3a60)
String is $VAR1 = "/F14 9 0 R /F27 10 0 R >>\n/ProcSet [ /PDF /Text ]\n>>\n<<\n/Type /Page\n/Contents 15 0 R\n/Resources 13 0 R\n/MediaBox [0 0 595.276 841.89]\n/Parent 12 0 R\n>";
F14 is PDF::API2::Basic::PDF::Objind=HASH(0x3fd3bb0)
String is $VAR1 = "/F27 10 0 R >>\n/ProcSet [ /PDF /Text ]\n>>\n<<\n/Type /Page\n/Contents 15 0 R\n/Resources 13 0 R\n/MediaBox [0 0 595.276 841.89]\n/Parent 12 0 R\n>";
F27 is PDF::API2::Basic::PDF::Objind=HASH(0x3fcdb88)
Font is PDF::API2::Basic::PDF::Dict=HASH(0x4066a30)
String is $VAR1 = "/ProcSet [ /PDF /Text ]\n>>\n<<\n/Type /Page\n/Contents 15 0 R\n/Resources 13 0 R\n/MediaBox [0 0 595.276 841.89]\n/Parent 12 0 R\n>";
Can't parse ` /PDF /Text ]
Show quoted text<<
/Type /Page
/Contents 15 0 R
/Resources 13 0 R
/MediaBox [0 0 595.276 841.89]
/Parent 12 0 R
Show quoted text>' near 136332 length 114. at /home/melmoth/perl5/lib/perl5/PDF/API2/Basic/PDF/File.pm line 665.
It looks like another problem, though, as the openining with the
whitespace removing is OK (or just looks so).
diff --git a/lib/PDF/API2/Basic/PDF/File.pm b/lib/PDF/API2/Basic/PDF/File.pm
index 1f46d46..84e6e1b 100644
--- a/lib/PDF/API2/Basic/PDF/File.pm
+++ b/lib/PDF/API2/Basic/PDF/File.pm
@@ -139,6 +139,7 @@ is in PDF which contains the location of the previous cross-reference table.
=cut
use strict;
+use Data::Dumper;
no strict "refs";
use Scalar::Util qw(blessed);
@@ -464,9 +465,14 @@ sub readval {
$result = PDFDict();
while ($str !~ m/^>>/) {
+ # remove a leading newline if present
+ $Data::Dumper::Useqq = 1;
+ print "String is " . Dumper($str);
+ $str =~ s/\A$ws_char//;
if ($str =~ s|^/($reg_char+)$ws_char?||) {
my $key = PDF::API2::Basic::PDF::Name::name_to_string($1, $self);
($value, $str) = $self->readval($str, %opts);
+ print "$key is $value\n";
$result->{$key} = $value;
}
elsif ($str =~ s|^/$ws_char+||) {
@@ -479,6 +485,9 @@ sub readval {
($value, $str) = $self->readval($str, %opts);
$result->{'null'} = $value;
}
+ else {
+ die "None of the above changes $str: $reg_char or $ws_char\n";
+ }
$str = update($fh, $str) if $update; # thanks gareth.jones@stud.man.ac.uk
}
$str =~ s/^>>//;
--
Marco