Subject: | Add file attachment annotations |
The following patch against 2.028 adds file attachment annotations.
Subject: | PDF-API2-2.028-Annotation-attachment.patch |
*** PDF/API2/Annotation.pm~ 2016-06-09 00:24:09.000000000 +0200
--- PDF/API2/Annotation.pm 2016-09-18 17:14:50.732315208 +0200
***************
*** 204,209 ****
--- 204,254 ----
return($self);
}
+ =item $ant->fileattachment $file, %opts
+
+ Defines the annotation as a file attachment with file $file and
+ options %opts (-rect, -border, -content (type), -icon (name)).
+
+ =cut
+
+ sub fileattachment {
+ my ( $self, $file, %opts ) = @_;
+
+ # https://books.google.nl/books?id=1TpDgwNGIK8C&pg=PA97&lpg=PA97&dq=pdf+embeddedfile+fileattachment&source=bl&ots=oGyUXkDBUT&sig=aftnbcBQlkOwcHLPdYxE4pcBIP4&hl=en&sa=X&ved=0ahUKEwjW2vnmjIrPAhXIfxoKHVsACTAQ6AEIQjAF#v=onepage&q=pdf%20embeddedfile%20fileattachment&f=false
+ #
+ # /Annots
+ # [ << /FS << /EF << /F 8 0 R >> /F (attachment.txt) /Type /F >>
+ # /Subtype /FileAttachment
+ # /Contents (attachment.txt)
+ # /Rect [ 18 796 45 823 ]
+ # >> ]
+
+ my $contentype = delete $opts{-content};
+ my $icontype = delete $opts{-icon};
+
+ $self->{Subtype} = PDFName('FileAttachment');
+ if ( is_utf8($file)) {
+ # URI must be 7-bit ascii
+ utf8::downgrade($file);
+ }
+ $self->{Contents} = PDFStr($file);
+ $self->{Name} = PDFName( $icontype || 'None');
+
+ $self->{FS} = PDFDict();
+ $self->{FS}->{F} = PDFStr($file);
+ $self->{FS}->{Type} = PDFName('F');
+ $self->{FS}->{EF} = PDFDict($file);
+ $self->{FS}->{EF}->{F} = PDFDict($file);
+ $self->{' apipdf'}->new_obj($self->{FS}->{EF}->{F});
+ $self->{FS}->{EF}->{F}->{Type} = PDFName('EmbeddedFile');
+ $self->{FS}->{EF}->{F}->{SubType} = PDFName($contentype) if $contentype;
+ $self->{FS}->{EF}->{F}->{' streamfile'}=$file;
+
+ $self->rect(@{$opts{-rect}}) if (defined $opts{-rect});
+ $self->border(@{$opts{-border}}) if (defined $opts{-border});
+ return($self);
+ }
+
=item $ant->rect $llx, $lly, $urx, $ury
Sets the rectangle of the annotation.