CAM-PDF-Annot

 view release on metacpan or  search on metacpan

lib/CAM/PDF/Annot.pm  view on Meta::CPAN

67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
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

126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
        $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

157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
                                 
                                # 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

194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
}
 
=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.294 second using v1.01-cache-2.11-cpan-cba739cd03b )