CAM-PDF-Annot
view release on metacpan or search on metacpan
lib/CAM/PDF/Annot.pm view on Meta::CPAN
It was only tested for annotations of /Type /Annot and /Subtype
/Square, /Circle, /Polygon and /Text. It is hardcoded to not allow any other
subtypes (sometime in the future this may change).
It takes a hash reference C<$refKeys> and adds the altered keys so it can
be used across calls and update references across objects (and avoid
adding the same object more than once).
=cut
sub appendAnnotation($$$\%) {
my ( $self, $page, $otherDoc, $otherAnnotRef, $refKeys ) = @_;
# Sanity check: it only appends objects of /Type /Annot /Subtype /Square|Circle|Polygon|Text
# returns an empty hash reference
return {} if ( $otherDoc->getValue( $otherAnnotRef )->{Subtype}{value} !~ /(Square|Circle|Polygon|Text)/ );
# If document does not have annots in this page, create an annots property
unless ( exists $self->getPage( $page )->{Annots} ) {
$self->getPage( $page )->{Annots} = CAM::PDF::Node->new('array',[], scalar $self->getPageObjnum( $page ),'0');
}
lib/CAM/PDF/Annot.pm view on Meta::CPAN
$self->changeRefKeys( $self->{objcache}{$newkey}, $refKeys );
if (wantarray) {
return ($newkey, %$refKeys);
}
else {
return $newkey;
}
}
sub _appendAppearanceObject() {
my ( $self, $otherDoc, $annotRef, $refKeys ) = @_;
my $annotVal = $self->getValue( $annotRef );
my %refs =();
# Check if this annot has a reference to an APeareance object
# (it is expected it will have it...)
if ( exists $annotVal->{AP} ) {
my $ap = $self->getValue( $annotVal->{AP} );
# Check if it wasn't already added before
unless ( exists $refKeys->{$ap->{N}{value}} ) {
lib/CAM/PDF/Annot.pm view on Meta::CPAN
# keep track of this addition
$$refKeys{$ap->{D}{value}} = $apDkey;
$refs{$ap->{D}{value}} = $apDkey;
}
}
}
return %refs;
}
sub _appendPopupObject() {
my ( $self, $page, $otherDoc, $annotRef, $parentKeys, $refKeys ) = @_;
my $annotVal = $self->getValue( $annotRef );
my $annots = $self->getPage( $page )->{Annots};
my %refs =();
# Now check if it has a reference to a popup object
# (it is bound to have it...)
# And also check if it wasnt already added
if ( exists $annotVal->{Popup} ) {
unless ( exists $refKeys->{$annotVal->{Popup}{value}} ) {
lib/CAM/PDF/Annot.pm view on Meta::CPAN
}
=item $doc->getAnnotations( $page )
Returns an array reference to the Annots array of the page. The array
contains CAM::PDF::Nodes (see C<CAM::PDF>) of type 'reference' refering
to the annotations.
=cut
sub getAnnotations($) {
my ( $self, $p ) = @_;
return $self->getValue( $self->getPage( $p )->{Annots} ) || [];
}
1;
__END__
=back
=head1 CAVEATS
( run in 0.718 second using v1.01-cache-2.11-cpan-65fba6d93b7 )