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