Skip Menu |
 

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

Report information
The Basics
Id: 69503
Status: resolved
Priority: 0/
Queue: PDF-API2

People
Owner: Nobody in particular
Requestors: dietrich.streifert [...] googlemail.com
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 2.019
Fixed in: 2.022



Subject: $pdf->preferences( -firstpage => [ 1, -fit => 1 ] ) leads ot error in API2::Basic::PDF::Array.pm
Download (untitled) / with headers
text/plain 458b
When trying to set preferences with PDF::API2::preferences e.g. like my %options = ( -firstpage => [ 2, -fit => 1 ] ); $pdf->preferences(%options); leads ot an error in API2::Basic::PDF::Array.pm. This is due to the fact that the paramter page (in the example code 2) is passed to PDFArray without being passed through PDFNum. A patch against version 2.019 is attached which fixes the problem by enveloping the pagenumer with a PDFNum call.
Subject: API2.pm.diff
Download API2.pm.diff
text/x-diff 2.2k
--- API2.pm.orig 2011-07-15 16:16:39.000000000 +0200 +++ API2.pm 2011-07-15 16:18:18.000000000 +0200 @@ -476,23 +476,23 @@ $o{-fit}=1 if(scalar(keys %o)<1); if(defined $o{-fit}) { - $self->{catalog}->{OpenAction}=PDFArray($page,PDFName('Fit')); + $self->{catalog}->{OpenAction}=PDFArray(PDFNum($page),PDFName('Fit')); } elsif(defined $o{-fith}) { - $self->{catalog}->{OpenAction}=PDFArray($page,PDFName('FitH'),PDFNum($o{-fith})); + $self->{catalog}->{OpenAction}=PDFArray(PDFNum($page),PDFName('FitH'),PDFNum($o{-fith})); } elsif(defined $o{-fitb}) { - $self->{catalog}->{OpenAction}=PDFArray($page,PDFName('FitB')); + $self->{catalog}->{OpenAction}=PDFArray(PDFNum($page),PDFName('FitB')); } elsif(defined $o{-fitbh}) { - $self->{catalog}->{OpenAction}=PDFArray($page,PDFName('FitBH'),PDFNum($o{-fitbh})); + $self->{catalog}->{OpenAction}=PDFArray(PDFNum($page),PDFName('FitBH'),PDFNum($o{-fitbh})); } elsif(defined $o{-fitv}) { - $self->{catalog}->{OpenAction}=PDFArray($page,PDFName('FitV'),PDFNum($o{-fitv})); + $self->{catalog}->{OpenAction}=PDFArray(PDFNum($page),PDFName('FitV'),PDFNum($o{-fitv})); } elsif(defined $o{-fitbv}) { - $self->{catalog}->{OpenAction}=PDFArray($page,PDFName('FitBV'),PDFNum($o{-fitbv})); + $self->{catalog}->{OpenAction}=PDFArray(PDFNum($page),PDFName('FitBV'),PDFNum($o{-fitbv})); } elsif(defined $o{-fitr}) { die "insufficient parameters to -fitr => [] " unless(scalar @{$o{-fitr}} == 4); - $self->{catalog}->{OpenAction}=PDFArray($page,PDFName('FitR'),map {PDFNum($_)} @{$o{-fitr}}); + $self->{catalog}->{OpenAction}=PDFArray(PDFNum($page),PDFName('FitR'),map {PDFNum($_)} @{$o{-fitr}}); } elsif(defined $o{-xyz}) { die "insufficient parameters to -xyz => [] " unless(scalar @{$o{-xyz}} == 3); - $self->{catalog}->{OpenAction}=PDFArray($page,PDFName('XYZ'),map {PDFNum($_)} @{$o{-xyz}}); + $self->{catalog}->{OpenAction}=PDFArray(PDFNum($page),PDFName('XYZ'),map {PDFNum($_)} @{$o{-xyz}}); } } $self->{pdf}->out_obj($self->{catalog});
Download (untitled) / with headers
text/plain 166b
add: The error message is: Can't call method "outobj" without a package or object reference at /usr/lib/perl5/site_perl/5.10.0/PDF/API2/Basic/PDF/Array.pm line 69.
Thanks for the bug report and patch. This is now fixed, and will be included in the next release.
Download (untitled) / with headers
text/plain 1.3k
On Thu Jun 12 23:04:09 2014, SSIMMS wrote: Show quoted text
> Thanks for the bug report and patch. This is now fixed, and will be > included in the next release.
Hello there. It looks like this change creates some backward incompatibility issues (or documentation bug), as it is not clear what $page is, if a page object or a number. Doc says: Initial Page Options: -firstpage => [ $page, %options ] Specifying the page to be displayed, plus one of the following options: Passing a page object, as we used to do, the result is a weird stringification and produce an invalid PDF. (evince opens it, but mupdf barfs and exit). 1 0 obj << /Type /Catalog /OpenAction [ PDF::API2::Page=HASH(0x23090b8) /Fit ] /PageLayout /SinglePage /PageMode /UseNone /Pages 2 0 R /ViewerPreferences << /NonFullScreenPageMode /UseNone >> >> endobj ############## cut ################# #!perl use strict; use warnings; use PDF::API2; use Test::More tests => 1; my $pdf = PDF::API2->new; my $font = $pdf->corefont('Helvetica-Bold'); my $page = $pdf->page; my $text = $page->text; $text->font($font, 20); $text->text('Hello world'); $pdf->preferences( -firstpage => [ $page, -fit => 0], ); my $string = $pdf->stringify; unlike $string, qr/PDF::API2::Page=HASH/; ######### cut ################à Best wishes and thanks in advance.
Download (untitled) / with headers
text/plain 791b
On Thu Sep 11 04:19:53 2014, MELMOTHX wrote: Show quoted text
> On Thu Jun 12 23:04:09 2014, SSIMMS wrote:
> > Thanks for the bug report and patch. This is now fixed, and will be > > included in the next release.
> > Hello there. It looks like this change creates some backward > incompatibility issues (or documentation bug), as it is not clear what > $page is, if a page object or a number.
You're right, this wasn't clear, and the fix broke the case where a page object was passed, which is what the code was originally expecting. I've just updated the code to accept either a page reference or a page number (the PDF specification allows both, which I didn't notice originally), clarified the documentation, and will have a new release on CPAN momentarily. Thanks for the bug report and test. Steve


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.