| 1 | package PDF::Builder::Resource::XObject::Form; | ||||||||||||||||||||
| 2 | |||||||||||||||||||||
| 3 | 39 | ▶ | use base 'PDF::Builder::Resource::XObject'; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 4 | |||||||||||||||||||||
| 5 | 39 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 6 | 39 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 7 | |||||||||||||||||||||
| 8 | 39 | our $VERSION = '3.028'; # VERSION | |||||||||||||||||||
| 9 | 39 | our $LAST_UPDATE = '3.027'; # manually update whenever code is changed | |||||||||||||||||||
| 10 | |||||||||||||||||||||
| 11 | 39 | ▶ | use PDF::Builder::Basic::PDF::Utils; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 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 | 10 | ▶ | sub new { | ||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 34 | 10 | my ($class, $pdf, $name) = @_; | |||||||||||||||||||
| 35 | |||||||||||||||||||||
| 36 | 10 | my $self = $class->SUPER::new($pdf, $name); | |||||||||||||||||||
| 37 | |||||||||||||||||||||
| 38 | 10 | $self->subtype('Form'); | |||||||||||||||||||
| 39 | 10 | $self->{'FormType'} = PDFNum(1); | |||||||||||||||||||
| 40 | |||||||||||||||||||||
| 41 | 10 | 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 | 11 | ▶ | sub bbox { | ||||||||||||||||||
|
Subroutine
bbox: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 57 | 11 | my $self = shift(); | |||||||||||||||||||
| 58 | |||||||||||||||||||||
| 59 | 11 | ▶ | if (scalar @_) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 60 | 10 | $self->{'BBox'} = PDFArray(map { PDFNum($_) } @_); | |||||||||||||||||||
| 61 | } | ||||||||||||||||||||
| 62 | |||||||||||||||||||||
| 63 | 11 | return map { $_->val() } $self->{'BBox'}->elements(); | |||||||||||||||||||
| 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 | 0 | ▶ | sub resource { | ||||||||||||||||||
|
Subroutine
resource: not called CC=9 SCAR=45.0
Pod
documented
| |||||||||||||||||||||
| 83 | 0 | my ($self, $type, $key, $object, $force) = @_; | |||||||||||||||||||
| 84 | # we are a self-contained content stream. | ||||||||||||||||||||
| 85 | |||||||||||||||||||||
| 86 | 0 | ▶ | $self->{'Resources'} ||= PDFDict(); | ||||||||||||||||||
|
Condition0%0/3
$self->{"Resources"} ||= PDFDict()
MC/DC0%0/2
$self->{"Resources"} ||= PDFDict()
$self->{"Resources"}
PDFDict()
Truth table0%0/3
A ||= B
A= $self->{"Resources"}B= PDFDict()
| |||||||||||||||||||||
| 87 | |||||||||||||||||||||
| 88 | 0 | my $dict = $self->{'Resources'}; | |||||||||||||||||||
| 89 | 0 | ▶ | $dict->realise() if ref($dict) =~ /Objind$/; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 90 | |||||||||||||||||||||
| 91 | 0 | ▶ | $dict->{$type} ||= PDFDict(); | ||||||||||||||||||
|
Condition0%0/3
$dict->{$type} ||= PDFDict()
MC/DC0%0/2
$dict->{$type} ||= PDFDict()
$dict->{$type}
PDFDict()
Truth table0%0/3
A ||= B
A= $dict->{$type}B= PDFDict()
| |||||||||||||||||||||
| 92 | 0 | ▶ | $dict->{$type}->realise() if ref($dict->{$type}) =~ /Objind$/; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 93 | |||||||||||||||||||||
| 94 | 0 | ▶ | unless (defined $object) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 95 | 0 | ▶ | return $dict->{$type}->{$key} || undef; | ||||||||||||||||||
|
Condition0%0/2
$dict->{$type}{$key} || undef
MC/DC0%0/1
$dict->{$type}{$key} || undef
$dict->{$type}{$key}
Truth table0%0/2
A
A= $dict->{$type}{$key}
| |||||||||||||||||||||
| 96 | } | ||||||||||||||||||||
| 97 | |||||||||||||||||||||
| 98 | 0 | ▶ | if ($force) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 99 | 0 | $dict->{$type}->{$key} = $object; | |||||||||||||||||||
| 100 | } | ||||||||||||||||||||
| 101 | else { | ||||||||||||||||||||
| 102 | 0 | ▶ | $dict->{$type}->{$key} ||= $object; | ||||||||||||||||||
|
Condition0%0/3
$dict->{$type}{$key} ||= $object
MC/DC0%0/2
$dict->{$type}{$key} ||= $object
$dict->{$type}{$key}
$object
Truth table0%0/3
A ||= B
A= $dict->{$type}{$key}B= $object
| |||||||||||||||||||||
| 103 | } | ||||||||||||||||||||
| 104 | |||||||||||||||||||||
| 105 | 0 | return $dict; | |||||||||||||||||||
| 106 | } | ||||||||||||||||||||
| 107 | |||||||||||||||||||||
| 108 | 39 | 1; | |||||||||||||||||||