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