| 1 | #======================================================================= | ||||||||||||||||||||
| 2 | # ____ ____ _____ _ ____ ___ ____ | ||||||||||||||||||||
| 3 | # | _ \| _ \| ___| _ _ / \ | _ \_ _| |___ \ | ||||||||||||||||||||
| 4 | # | |_) | | | | |_ (_) (_) / _ \ | |_) | | __) | | ||||||||||||||||||||
| 5 | # | __/| |_| | _| _ _ / ___ \| __/| | / __/ | ||||||||||||||||||||
| 6 | # |_| |____/|_| (_) (_) /_/ \_\_| |___| |_____| | ||||||||||||||||||||
| 7 | # | ||||||||||||||||||||
| 8 | # A Perl Module Chain to faciliate the Creation and Modification | ||||||||||||||||||||
| 9 | # of High-Quality "Portable Document Format (PDF)" Files. | ||||||||||||||||||||
| 10 | # | ||||||||||||||||||||
| 11 | # Copyright 1999-2005 Alfred Reibenschuh <areibens@cpan.org>. | ||||||||||||||||||||
| 12 | # | ||||||||||||||||||||
| 13 | #======================================================================= | ||||||||||||||||||||
| 14 | # | ||||||||||||||||||||
| 15 | # This library is free software; you can redistribute it and/or | ||||||||||||||||||||
| 16 | # modify it under the terms of the GNU Lesser General Public | ||||||||||||||||||||
| 17 | # License as published by the Free Software Foundation; either | ||||||||||||||||||||
| 18 | # version 2 of the License, or (at your option) any later version. | ||||||||||||||||||||
| 19 | # | ||||||||||||||||||||
| 20 | # This library is distributed in the hope that it will be useful, | ||||||||||||||||||||
| 21 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||||||||||||||||||
| 22 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||||||||||||||||||||
| 23 | # Lesser General Public License for more details. | ||||||||||||||||||||
| 24 | # | ||||||||||||||||||||
| 25 | # You should have received a copy of the GNU Lesser General Public | ||||||||||||||||||||
| 26 | # License along with this library; if not, write to the | ||||||||||||||||||||
| 27 | # Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||||||||||||||||||||
| 28 | # Boston, MA 02111-1307, USA. | ||||||||||||||||||||
| 29 | # | ||||||||||||||||||||
| 30 | # $Id: Form.pm,v 2.0 2005/11/16 02:18:23 areibens Exp $ | ||||||||||||||||||||
| 31 | # | ||||||||||||||||||||
| 32 | #======================================================================= | ||||||||||||||||||||
| 33 | package PDF::API3::Compat::API2::Resource::XObject::Form; | ||||||||||||||||||||
| 34 | |||||||||||||||||||||
| 35 | 1 | ▶ | BEGIN { | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 36 | |||||||||||||||||||||
| 37 | 1 | ▶ | use PDF::API3::Compat::API2::Util; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 38 | 1 | ▶ | use PDF::API3::Compat::API2::Basic::PDF::Utils; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 39 | 1 | ▶ | use PDF::API3::Compat::API2::Resource::XObject; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 40 | |||||||||||||||||||||
| 41 | 1 | ▶ | use POSIX; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 42 | |||||||||||||||||||||
| 43 | 1 | ▶ | use vars qw(@ISA $VERSION); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 44 | |||||||||||||||||||||
| 45 | 1 | @ISA = qw( PDF::API3::Compat::API2::Resource::XObject ); | |||||||||||||||||||
| 46 | |||||||||||||||||||||
| 47 | 1 | ( $VERSION ) = sprintf '%i.%03i', split(/\./,('$Revision: 2.0 $' =~ /Revision: (\S+)\s/)[0]); # $Date: 2005/11/16 02:18:23 $ | |||||||||||||||||||
| 48 | |||||||||||||||||||||
| 49 | } | ||||||||||||||||||||
| 50 | 1 | ▶ | no warnings qw[ deprecated recursion uninitialized ]; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 51 | |||||||||||||||||||||
| 52 | =item $res = PDF::API3::Compat::API2::Resource::XObject::Form->new $pdf | ||||||||||||||||||||
| 53 | |||||||||||||||||||||
| 54 | Returns a form-resource object. base class for all types of form-xobjects. | ||||||||||||||||||||
| 55 | |||||||||||||||||||||
| 56 | =cut | ||||||||||||||||||||
| 57 | |||||||||||||||||||||
| 58 | 0 | ▶ | sub new { | ||||||||||||||||||
|
Subroutine
new: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||
| 59 | 0 | my ($class,$pdf) = @_; | |||||||||||||||||||
| 60 | 0 | my $self; | |||||||||||||||||||
| 61 | |||||||||||||||||||||
| 62 | 0 | ▶ | $class = ref $class if ref $class; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 63 | |||||||||||||||||||||
| 64 | 0 | $self=$class->SUPER::new($pdf,pdfkey()); | |||||||||||||||||||
| 65 | 0 | ▶ | $pdf->new_obj($self) unless($self->is_obj($pdf)); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 66 | |||||||||||||||||||||
| 67 | 0 | $self->subtype('Form'); | |||||||||||||||||||
| 68 | 0 | $self->{FormType}=PDFNum(1); | |||||||||||||||||||
| 69 | |||||||||||||||||||||
| 70 | 0 | $self->{' apipdf'}=$pdf; | |||||||||||||||||||
| 71 | |||||||||||||||||||||
| 72 | 0 | return($self); | |||||||||||||||||||
| 73 | } | ||||||||||||||||||||
| 74 | |||||||||||||||||||||
| 75 | =item $res = PDF::API3::Compat::API2::Resource::XObject::Form->new_api $api, $name | ||||||||||||||||||||
| 76 | |||||||||||||||||||||
| 77 | Returns a form resource object. This method is different from 'new' that | ||||||||||||||||||||
| 78 | it needs an PDF::API3::Compat::API2-object rather than a Text::PDF::File-object. | ||||||||||||||||||||
| 79 | |||||||||||||||||||||
| 80 | =cut | ||||||||||||||||||||
| 81 | |||||||||||||||||||||
| 82 | 0 | ▶ | sub new_api { | ||||||||||||||||||
|
Subroutine
new_api: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 83 | 0 | my ($class,$api,@opts)=@_; | |||||||||||||||||||
| 84 | |||||||||||||||||||||
| 85 | 0 | my $obj=$class->new($api->{pdf},@opts); | |||||||||||||||||||
| 86 | 0 | $obj->{' api'}=$api; | |||||||||||||||||||
| 87 | |||||||||||||||||||||
| 88 | 0 | return($obj); | |||||||||||||||||||
| 89 | } | ||||||||||||||||||||
| 90 | |||||||||||||||||||||
| 91 | =item ($llx, $lly, $urx, $ury) = $res->bbox $llx, $lly, $urx, $ury | ||||||||||||||||||||
| 92 | |||||||||||||||||||||
| 93 | =cut | ||||||||||||||||||||
| 94 | |||||||||||||||||||||
| 95 | 0 | ▶ | sub bbox { | ||||||||||||||||||
|
Subroutine
bbox: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||
| 96 | 0 | my $self = shift @_; | |||||||||||||||||||
| 97 | 0 | my @b; | |||||||||||||||||||
| 98 | 0 | ▶ | if(@b=@_){ | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 99 | 0 | $self->{BBox}=PDFArray(map { PDFNum($_) } @b); | |||||||||||||||||||
| 100 | } | ||||||||||||||||||||
| 101 | 0 | @b=$self->{BBox}->elementsof; | |||||||||||||||||||
| 102 | 0 | return(map { $_->val } @b); | |||||||||||||||||||
| 103 | } | ||||||||||||||||||||
| 104 | |||||||||||||||||||||
| 105 | =item $res->resource $type, $key, $obj | ||||||||||||||||||||
| 106 | |||||||||||||||||||||
| 107 | Adds a resource to the form. | ||||||||||||||||||||
| 108 | |||||||||||||||||||||
| 109 | B<Example:> | ||||||||||||||||||||
| 110 | |||||||||||||||||||||
| 111 | $res->resource('Font',$fontkey,$fontobj); | ||||||||||||||||||||
| 112 | $res->resource('XObject',$imagekey,$imageobj); | ||||||||||||||||||||
| 113 | $res->resource('Shading',$shadekey,$shadeobj); | ||||||||||||||||||||
| 114 | $res->resource('ColorSpace',$spacekey,$speceobj); | ||||||||||||||||||||
| 115 | |||||||||||||||||||||
| 116 | B<Note:> You only have to add the required resources, if | ||||||||||||||||||||
| 117 | they are NOT handled by the *font*, *image*, *shade* or *space* | ||||||||||||||||||||
| 118 | methods. | ||||||||||||||||||||
| 119 | |||||||||||||||||||||
| 120 | =cut | ||||||||||||||||||||
| 121 | |||||||||||||||||||||
| 122 | 0 | ▶ | sub resource { | ||||||||||||||||||
|
Subroutine
resource: not called CC=9 SCAR=45.0
Pod
documented
| |||||||||||||||||||||
| 123 | 0 | my ($self, $type, $key, $obj, $force) = @_; | |||||||||||||||||||
| 124 | # we are a self-contained content stream. | ||||||||||||||||||||
| 125 | |||||||||||||||||||||
| 126 | 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()
| |||||||||||||||||||||
| 127 | |||||||||||||||||||||
| 128 | 0 | my $dict=$self->{Resources}; | |||||||||||||||||||
| 129 | 0 | ▶ | $dict->realise if(ref($dict)=~/Objind$/); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 130 | |||||||||||||||||||||
| 131 | 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()
| |||||||||||||||||||||
| 132 | 0 | ▶ | $dict->{$type}->realise if(ref($dict->{$type})=~/Objind$/); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 133 | 0 | ▶ | unless (defined $obj) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 134 | 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}
| |||||||||||||||||||||
| 135 | } else { | ||||||||||||||||||||
| 136 | 0 | ▶ | if($force) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 137 | 0 | $dict->{$type}->{$key}=$obj; | |||||||||||||||||||
| 138 | } else { | ||||||||||||||||||||
| 139 | 0 | ▶ | $dict->{$type}->{$key}||= $obj; | ||||||||||||||||||
|
Condition0%0/3
$dict->{$type}{$key} ||= $obj
MC/DC0%0/2
$dict->{$type}{$key} ||= $obj
$dict->{$type}{$key}
$obj
Truth table0%0/3
A ||= B
A= $dict->{$type}{$key}B= $obj
| |||||||||||||||||||||
| 140 | } | ||||||||||||||||||||
| 141 | 0 | return($dict); | |||||||||||||||||||
| 142 | } | ||||||||||||||||||||
| 143 | } | ||||||||||||||||||||
| 144 | |||||||||||||||||||||
| 145 | 0 | ▶ | sub outobjdeep { | ||||||||||||||||||
|
Subroutine
outobjdeep: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||
| 146 | 0 | my ($self, @opts) = @_; | |||||||||||||||||||
| 147 | 0 | foreach my $k (qw/ api apipdf /) { | |||||||||||||||||||
| 148 | 0 | $self->{" $k"}=undef; | |||||||||||||||||||
| 149 | 0 | delete($self->{" $k"}); | |||||||||||||||||||
| 150 | } | ||||||||||||||||||||
| 151 | 0 | $self->SUPER::outobjdeep(@opts); | |||||||||||||||||||
| 152 | } | ||||||||||||||||||||
| 153 | |||||||||||||||||||||
| 154 | |||||||||||||||||||||
| 155 | 1 | 1; | |||||||||||||||||||
| 156 | |||||||||||||||||||||
| 157 | __END__ | ||||||||||||||||||||