line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package PDF::Builder::Resource::XObject::Form; |
2
|
|
|
|
|
|
|
|
3
|
34
|
|
|
34
|
|
319
|
use base 'PDF::Builder::Resource::XObject'; |
|
34
|
|
|
|
|
97
|
|
|
34
|
|
|
|
|
16520
|
|
4
|
|
|
|
|
|
|
|
5
|
34
|
|
|
34
|
|
243
|
use strict; |
|
34
|
|
|
|
|
83
|
|
|
34
|
|
|
|
|
661
|
|
6
|
34
|
|
|
34
|
|
177
|
use warnings; |
|
34
|
|
|
|
|
83
|
|
|
34
|
|
|
|
|
1688
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '3.023'; # VERSION |
9
|
|
|
|
|
|
|
our $LAST_UPDATE = '2.031'; # manually update whenever code is changed |
10
|
|
|
|
|
|
|
|
11
|
34
|
|
|
34
|
|
214
|
use PDF::Builder::Basic::PDF::Utils; |
|
34
|
|
|
|
|
83
|
|
|
34
|
|
|
|
|
14567
|
|
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
|
39
|
my ($class, $pdf, $name) = @_; |
29
|
|
|
|
|
|
|
|
30
|
10
|
|
|
|
|
73
|
my $self = $class->SUPER::new($pdf, $name); |
31
|
|
|
|
|
|
|
|
32
|
10
|
|
|
|
|
73
|
$self->subtype('Form'); |
33
|
10
|
|
|
|
|
33
|
$self->{'FormType'} = PDFNum(1); |
34
|
|
|
|
|
|
|
|
35
|
10
|
|
|
|
|
29
|
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
|
36
|
my $self = shift(); |
46
|
|
|
|
|
|
|
|
47
|
11
|
100
|
|
|
|
45
|
if (scalar @_) { |
48
|
10
|
|
|
|
|
26
|
$self->{'BBox'} = PDFArray(map { PDFNum($_) } @_); |
|
40
|
|
|
|
|
101
|
|
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
11
|
|
|
|
|
66
|
return map { $_->val() } $self->{'BBox'}->elements(); |
|
44
|
|
|
|
|
97
|
|
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; |