Subject: | $pdf->preferences( -firstpage => [ 1, -fit => 1 ] ) leads ot error in API2::Basic::PDF::Array.pm |
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 |
--- 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});