File Coverage

blib/lib/Khonsu/Form.pm
Criterion Covered Total %
statement 24 24 100.0
branch 2 2 100.0
condition n/a
subroutine 6 6 100.0
pod 0 4 0.0
total 32 36 88.8


line stmt bran cond sub pod time code
1             package Khonsu::Form;
2              
3 5     5   43 use parent 'Khonsu::Ra';
  5         11  
  5         28  
4              
5 5     5   335 use PDF::API2::Basic::PDF::Utils;
  5         10  
  5         1792  
6              
7             sub attributes {
8 4     4 0 167 my $a = shift;
9             return (
10 4         87 form => { $a->RW, $a->OBJ },
11             fields => { $a->RW, $a->AR },
12             );
13             }
14              
15             sub add {
16 7     7 0 18 my ($self, $file, %args) = @_;
17 7 100       45 return $self if $self->form;
18 3         14 my $form = PDFDict();
19 3         71 $form->{NeedAppearances} = PDFBool('true');
20 3         55 $self->form($form);
21 3         54 $file->onsave('form', 'end');
22             }
23              
24             sub end {
25 3     3 0 17 my ($self, $file) = @_;
26 3         7 $self->form->{Fields} = PDFArray(@{$self->fields});
  3         28  
27 3         31 $file->pdf->{catalog}->{AcroForm} = $self->form;
28             }
29              
30             sub add_to_fields {
31 7     7 0 18 my ($self, $file, $field) = @_;
32 7         32 $self->add($file);
33 7         60 my $fields = $self->fields;
34 7         15 push @{$fields}, $field;
  7         15  
35 7         31 return $self->fields($fields);
36              
37             }
38              
39             1;