Skip Menu |

This queue is for tickets about the PDF CPAN distribution.

Report information
The Basics
Id: 9078
Status: new
Priority: 0/
Queue: PDF

People
Owner: Nobody in particular
Requestors: david [...] landgren.net
Cc:
AdminCc:

Bug Information
Severity: Critical
Broken in: 111
Fixed in: (no value)



Subject: PDF.pm does not grok ghostscript-generated PDF documents
With version 1.11, and Perl 5.8.6, I cannot open documents generated by Ghostscript 7.05. In PDF::Parse, the TargetFile method contains the following code: $self->{"Last_XRef_Offset"} = $offset; ReadCrossReference_pass1 (\*FILE, $offset, $self); $self->{"Info"} = $self->GetObject ($self->{"Trailer"}{"/Info"}); When it gets to the last line above, $self->{Trailer} is still undef, and so GetObject blows up. I am not yet sure why. Here is the end of one of the attached files: xref 0 16 0000000000 65535 f 0000000548 00000 n 0000002737 00000 n 0000000489 00000 n 0000000894 00000 n 0000000746 00000 n 0000000596 00000 n 0000000338 00000 n 0000000015 00000 n 0000000319 00000 n 0000001247 00000 n 0000001041 00000 n 0000002498 00000 n 0000000684 00000 n 0000000714 00000 n 0000002477 00000 n trailer << /Size 16 /Root 1 0 R /Info 2 0 R Show quoted text
>>
startxref 2787 %%EOF So the trailer is there, but the code doesn't locate it. When I run the attached script, it produces the following output: ./look portrait.pdf portrait.pdf Bad object reference '>' at ./look line 7 Bad object reference '>' at ./look line 7 Bad object reference '>' at ./look line 7 v=1.4 rot=
Download pdf-bug.tar.gz
application/x-gzip 4k

Message body not shown because it is not plain text.

From: david [...] landgren.net
[DLAND - Wed Dec 22 07:29:20 2004]: Show quoted text
> When it gets to the last line above, $self->{Trailer} is still undef, > and so GetObject blows up. I am not yet sure why. Here is the end of
The following patch appears to fix the problem. It looks like the code is pretty picky about where 'trailer' and '<<' should appear. As there is no test suite, it is difficult to know whether I have broken anything else :( david --- Parse.pm-dist Tue Feb 8 21:54:27 2000 +++ Parse.pm Wed Dec 22 14:22:34 2004 @@ -138,6 +138,7 @@ { $_=PDF::Core::PDFGetline ($fd,\$offset); } + $offset -= length($_)-index($_, '<<') - 2; # # Read the dictionary @@ -283,7 +284,7 @@ $self->{Header}= $buf; seek FILE,-50,2; read( FILE, $offset, 50 ); - $offset =~ s/[^s]*startxref\r?\n?(\d*)\r?\n?%%EOF\r?\n?/$1/; + $offset =~ /\bstartxref\s*(\d+)/m and $offset = $1; $self->{"Last_XRef_Offset"} = $offset; ReadCrossReference_pass1 (\*FILE, $offset, $self);