line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package PDF::Builder::Resource::XObject::Form; |
2
|
|
|
|
|
|
|
|
3
|
38
|
|
|
38
|
|
297
|
use base 'PDF::Builder::Resource::XObject'; |
|
38
|
|
|
|
|
84
|
|
|
38
|
|
|
|
|
14398
|
|
4
|
|
|
|
|
|
|
|
5
|
38
|
|
|
38
|
|
234
|
use strict; |
|
38
|
|
|
|
|
76
|
|
|
38
|
|
|
|
|
654
|
|
6
|
38
|
|
|
38
|
|
159
|
use warnings; |
|
38
|
|
|
|
|
73
|
|
|
38
|
|
|
|
|
1427
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '3.024'; # VERSION |
9
|
|
|
|
|
|
|
our $LAST_UPDATE = '2.031'; # manually update whenever code is changed |
10
|
|
|
|
|
|
|
|
11
|
38
|
|
|
38
|
|
194
|
use PDF::Builder::Basic::PDF::Utils; |
|
38
|
|
|
|
|
74
|
|
|
38
|
|
|
|
|
13707
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 NAME |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
PDF::Builder::Resource::XObject::Form - Base class for external form objects |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 METHODS |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=over |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=item $form = PDF::Builder::Resource::XObject::Form->new($pdf) |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
Creates a form resource. |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=cut |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub new { |
28
|
10
|
|
|
10
|
1
|
25
|
my ($class, $pdf, $name) = @_; |
29
|
|
|
|
|
|
|
|
30
|
10
|
|
|
|
|
55
|
my $self = $class->SUPER::new($pdf, $name); |
31
|
|
|
|
|
|
|
|
32
|
10
|
|
|
|
|
60
|
$self->subtype('Form'); |
33
|
10
|
|
|
|
|
24
|
$self->{'FormType'} = PDFNum(1); |
34
|
|
|
|
|
|
|
|
35
|
10
|
|
|
|
|
27
|
return $self; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=item ($llx, $lly, $urx, $ury) = $form->bbox($llx, $lly, $urx, $ury) |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
Get or set the coordinates of the form object's bounding box |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=cut |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub bbox { |
45
|
11
|
|
|
11
|
1
|
42
|
my $self = shift(); |
46
|
|
|
|
|
|
|
|
47
|
11
|
100
|
|
|
|
38
|
if (scalar @_) { |
48
|
10
|
|
|
|
|
32
|
$self->{'BBox'} = PDFArray(map { PDFNum($_) } @_); |
|
40
|
|
|
|
|
72
|
|
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
11
|
|
|
|
|
42
|
return map { $_->val() } $self->{'BBox'}->elements(); |
|
44
|
|
|
|
|
96
|
|
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=item $resource = $form->resource($type, $key) |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=item $form->resource($type, $key, $object, $force) |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
Get or add a resource required by the form's contents, such as a Font, XObject, ColorSpace, etc. |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
By default, an existing C<$key> will not be overwritten. Set C<$force> to override this behavior. |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=cut |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub resource { |
65
|
0
|
|
|
0
|
1
|
|
my ($self, $type, $key, $object, $force) = @_; |
66
|
|
|
|
|
|
|
# we are a self-contained content stream. |
67
|
|
|
|
|
|
|
|
68
|
0
|
|
0
|
|
|
|
$self->{'Resources'} ||= PDFDict(); |
69
|
|
|
|
|
|
|
|
70
|
0
|
|
|
|
|
|
my $dict = $self->{'Resources'}; |
71
|
0
|
0
|
|
|
|
|
$dict->realise() if ref($dict) =~ /Objind$/; |
72
|
|
|
|
|
|
|
|
73
|
0
|
|
0
|
|
|
|
$dict->{$type} ||= PDFDict(); |
74
|
0
|
0
|
|
|
|
|
$dict->{$type}->realise() if ref($dict->{$type}) =~ /Objind$/; |
75
|
|
|
|
|
|
|
|
76
|
0
|
0
|
|
|
|
|
unless (defined $object) { |
77
|
0
|
|
0
|
|
|
|
return $dict->{$type}->{$key} || undef; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
0
|
0
|
|
|
|
|
if ($force) { |
81
|
0
|
|
|
|
|
|
$dict->{$type}->{$key} = $object; |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
else { |
84
|
0
|
|
0
|
|
|
|
$dict->{$type}->{$key} ||= $object; |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
0
|
|
|
|
|
|
return $dict; |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=back |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=cut |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
1; |