This queue is for tickets about the PDF-API2 CPAN distribution.

Report information
The Basics

Nobody in particular
jv [...]

Broken in:
(no value)
Fixed in:

Subject: Unexplainable crash in some PDF documents
At least it is unexplainable for me... Test program attached. When I uncomment the offending line 322 in PDF/API2/ it seems to work but I cannot oversee the consequences of this change.
Subject: test.pdf

Message body not shown because it is not plain text.

use strict; use warnings; use PDF::API2 2.029; # or 2.028, ... my $pdf = PDF::API2->open("test.pdf"); my $page = $pdf->openpage(1); # This line will crash with # Can't locate object method "update" # via package "PDF::API2::Basic::PDF::Array" # at /usr/share/perl5/vendor_perl/PDF/API2/ line 322. my $ann = $page->annotation;
Initial troubleshooting: - Your test.pdf has an empty Annots (annotations) array on each page. - $page->annotation() creates a new annotation object, adds it to the page, and returns it. - Unrelated: $page->annotation() doesn't take any arguments -- the code declares three, but never uses them. It seems to be a copy-paste error from sub resource, which immediately follows it. I've just removed them. - If an annotations array already exists in the Page object [edit: and it's an indirect object], $page->annotation() tries to call update() on it. However, doesn't have an update() function, and it doesn't look like it ever did. - There are three cases of "sub update" in the codebase, and the only one that makes sense in this case is the one in, which "marks a page to be updated". It does this by calling's out_obj with itself as the argument. - out_obj notes that the object needs to be output when the PDF is generated (written to disk, stringified, etc.). - Therefore, it looks like the correct code for that line is... - $self->{'Annots'}->update(); + $self->{' apipdf'}->out_obj($self->{'Annots'}); ... because the purpose of the surrounding code seems to be "if an annotations array already exists, mark the array as having changed since we're about to add to it; otherwise, mark the page as having changed since we just added the annotations array to it." - However, that exact line already appears just after the new annotation is created. So, it does appear that just removing the line altogether will fix the crash without any consequences. While writing a test for this ticket, I also discovered that the crash only happens if the array is an indirect object -- if an array already exists and it's inline, there isn't a problem. This will be fixed in the next release, and working code is now in the repository.

This service runs on Request Tracker, is sponsored by The Perl Foundation, and maintained by Best Practical Solutions.

Please report any issues with to