| 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: Page.pm,v 2.1 2007/05/08 18:32:09 areibens Exp $ | ||||||||||||||||||||||||||||||||||
| 31 | # | ||||||||||||||||||||||||||||||||||
| 32 | #======================================================================= | ||||||||||||||||||||||||||||||||||
| 33 | package PDF::API3::Compat::API2::Page; | ||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||
| 35 | 1 | ▶ | BEGIN { | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||
| 37 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 38 | 1 | ▶ | use vars qw(@ISA %pgsz $VERSION); | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||
| 40 | 1 | @ISA = qw(PDF::API3::Compat::API2::Basic::PDF::Pages); | |||||||||||||||||||||||||||||||||
| 41 | 1 | ▶ | use PDF::API3::Compat::API2::Basic::PDF::Pages; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 42 | 1 | ▶ | use PDF::API3::Compat::API2::Basic::PDF::Utils; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 43 | 1 | ▶ | use PDF::API3::Compat::API2::Util; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||
| 45 | 1 | ▶ | use PDF::API3::Compat::API2::Annotation; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||
| 47 | 1 | ▶ | use PDF::API3::Compat::API2::Content; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 48 | 1 | ▶ | use PDF::API3::Compat::API2::Content::Text; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||
| 50 | 1 | ▶ | use PDF::API3::Compat::API2::Util; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||
| 52 | 1 | ▶ | use POSIX qw(floor ceil); | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 53 | 1 | ▶ | use Math::Trig; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||
| 55 | 1 | ( $VERSION ) = sprintf '%i.%03i', split(/\./,('$Revision: 2.1 $' =~ /Revision: (\S+)\s/)[0]); # $Date: 2007/05/08 18:32:09 $ | |||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||
| 59 | 1 | ▶ | no warnings qw[ deprecated recursion uninitialized ]; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||
| 61 | =head1 $page = PDF::API3::Compat::API2::Page->new $pdf, $parent, $index | ||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||
| 63 | Returns a page object (called from $pdf->page). | ||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||
| 65 | =cut | ||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||
| 67 | 0 | ▶ | sub new { | ||||||||||||||||||||||||||||||||
|
Subroutine
new: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 68 | 0 | my ($class, $pdf, $parent, $index) = @_; | |||||||||||||||||||||||||||||||||
| 69 | 0 | my ($self) = {}; | |||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||
| 71 | 0 | ▶ | $class = ref $class if ref $class; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 72 | 0 | $self = $class->SUPER::new($pdf, $parent); | |||||||||||||||||||||||||||||||||
| 73 | 0 | $self->{'Type'} = PDFName('Page'); | |||||||||||||||||||||||||||||||||
| 74 | 0 | $self->proc_set(qw( PDF Text ImageB ImageC ImageI )); | |||||||||||||||||||||||||||||||||
| 75 | 0 | delete $self->{'Count'}; | |||||||||||||||||||||||||||||||||
| 76 | 0 | delete $self->{'Kids'}; | |||||||||||||||||||||||||||||||||
| 77 | 0 | $parent->add_page($self, $index); | |||||||||||||||||||||||||||||||||
| 78 | 0 | $self; | |||||||||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||
| 81 | =item $page = PDF::API3::Compat::API2::Page->coerce $pdf, $pdfpage | ||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||
| 83 | Returns a page object converted from $pdfpage (called from $pdf->openpage). | ||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||
| 85 | =cut | ||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||
| 87 | 0 | ▶ | sub coerce { | ||||||||||||||||||||||||||||||||
|
Subroutine
coerce: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 88 | 0 | my ($class, $pdf, $page) = @_; | |||||||||||||||||||||||||||||||||
| 89 | 0 | my $self = $page; | |||||||||||||||||||||||||||||||||
| 90 | 0 | bless($self,$class); | |||||||||||||||||||||||||||||||||
| 91 | 0 | $self->{' apipdf'}=$pdf; | |||||||||||||||||||||||||||||||||
| 92 | 0 | return($self); | |||||||||||||||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||
| 95 | =item $page->update | ||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||
| 97 | Marks a page to be updated (by $pdf->update). | ||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||
| 99 | =cut | ||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||
| 101 | 0 | ▶ | sub update { | ||||||||||||||||||||||||||||||||
|
Subroutine
update: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 102 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||
| 103 | 0 | $self->{' apipdf'}->out_obj($self); | |||||||||||||||||||||||||||||||||
| 104 | 0 | $self; | |||||||||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||
| 107 | =item $page->mediabox $w, $h | ||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||
| 109 | =item $page->mediabox $llx, $lly, $urx, $ury | ||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||
| 111 | =item $page->mediabox $alias | ||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||
| 113 | Sets the mediabox. This method supports the following aliases: | ||||||||||||||||||||||||||||||||||
| 114 | '4A', '2A', 'A0', 'A1', 'A2', 'A3', 'A4', 'A5', 'A6', | ||||||||||||||||||||||||||||||||||
| 115 | '4B', '2B', 'B0', 'B1', 'B2', 'B3', 'B4', 'B5', 'B6', | ||||||||||||||||||||||||||||||||||
| 116 | 'LETTER', 'BROADSHEET', 'LEDGER', 'TABLOID', 'LEGAL', | ||||||||||||||||||||||||||||||||||
| 117 | 'EXECUTIVE', and '36X36'. | ||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||
| 119 | =cut | ||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||
| 121 | 0 | ▶ | sub mediabox { | ||||||||||||||||||||||||||||||||
|
Subroutine
mediabox: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 122 | 0 | my ($self,$x1,$y1,$x2,$y2) = @_; | |||||||||||||||||||||||||||||||||
| 123 | 0 | ▶ | if(defined $x2) { | ||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||
| 124 | $self->{'MediaBox'}=PDFArray( | ||||||||||||||||||||||||||||||||||
| 125 | 0 | map { PDFNum(float($_)) } ($x1,$y1,$x2,$y2) | |||||||||||||||||||||||||||||||||
| 126 | ); | ||||||||||||||||||||||||||||||||||
| 127 | } elsif(defined $y1) { | ||||||||||||||||||||||||||||||||||
| 128 | $self->{'MediaBox'}=PDFArray( | ||||||||||||||||||||||||||||||||||
| 129 | 0 | map { PDFNum(float($_)) } (0,0,$x1,$y1) | |||||||||||||||||||||||||||||||||
| 130 | ); | ||||||||||||||||||||||||||||||||||
| 131 | } else { | ||||||||||||||||||||||||||||||||||
| 132 | $self->{'MediaBox'}=PDFArray( | ||||||||||||||||||||||||||||||||||
| 133 | 0 | (map { PDFNum(float($_)) } page_size($x1)) | |||||||||||||||||||||||||||||||||
| 134 | ); | ||||||||||||||||||||||||||||||||||
| 135 | } | ||||||||||||||||||||||||||||||||||
| 136 | 0 | return($self); | |||||||||||||||||||||||||||||||||
| 137 | } | ||||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||||
| 139 | =item ($llx, $lly, $urx, $ury) = $page->get_mediabox | ||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||
| 141 | Gets the mediabox based one best estimates or the default. | ||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||
| 143 | =cut | ||||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||||
| 145 | 0 | ▶ | sub get_mediabox { | ||||||||||||||||||||||||||||||||
|
Subroutine
get_mediabox: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 146 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||
| 147 | 0 | my $media = [ 0, 0, 612, 792 ]; | |||||||||||||||||||||||||||||||||
| 148 | 0 | foreach my $mediatype ( | |||||||||||||||||||||||||||||||||
| 149 | qw( MediaBox CropBox BleedBox TrimBox ArtBox ) | ||||||||||||||||||||||||||||||||||
| 150 | ) { | ||||||||||||||||||||||||||||||||||
| 151 | 0 | my $mediaobj = undef; | |||||||||||||||||||||||||||||||||
| 152 | 0 | ▶ | if($mediaobj = $self->find_prop($mediatype)) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 153 | 0 | $media = [ map{ $_->val } $mediaobj->elementsof ]; | |||||||||||||||||||||||||||||||||
| 154 | 0 | last; | |||||||||||||||||||||||||||||||||
| 155 | } | ||||||||||||||||||||||||||||||||||
| 156 | } | ||||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||
| 158 | 0 | return(@{$media}); | |||||||||||||||||||||||||||||||||
| 159 | } | ||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||
| 161 | =item $page->cropbox $w, $h | ||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||
| 163 | =item $page->cropbox $llx, $lly, $urx, $ury | ||||||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||||
| 165 | =item $page->cropbox $alias | ||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||
| 167 | Sets the cropbox. This method supports the same aliases as mediabox. | ||||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||||
| 169 | =cut | ||||||||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||||||||
| 171 | 0 | ▶ | sub cropbox { | ||||||||||||||||||||||||||||||||
|
Subroutine
cropbox: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 172 | 0 | my ($self,$x1,$y1,$x2,$y2) = @_; | |||||||||||||||||||||||||||||||||
| 173 | 0 | ▶ | if(defined $x2) { | ||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||
| 174 | $self->{'CropBox'}=PDFArray( | ||||||||||||||||||||||||||||||||||
| 175 | 0 | map { PDFNum(float($_)) } ($x1,$y1,$x2,$y2) | |||||||||||||||||||||||||||||||||
| 176 | ); | ||||||||||||||||||||||||||||||||||
| 177 | } elsif(defined $y1) { | ||||||||||||||||||||||||||||||||||
| 178 | $self->{'CropBox'}=PDFArray( | ||||||||||||||||||||||||||||||||||
| 179 | 0 | map { PDFNum(float($_)) } (0,0,$x1,$y1) | |||||||||||||||||||||||||||||||||
| 180 | ); | ||||||||||||||||||||||||||||||||||
| 181 | } else { | ||||||||||||||||||||||||||||||||||
| 182 | $self->{'CropBox'}=PDFArray( | ||||||||||||||||||||||||||||||||||
| 183 | 0 | (map { PDFNum(float($_)) } page_size($x1)) | |||||||||||||||||||||||||||||||||
| 184 | ); | ||||||||||||||||||||||||||||||||||
| 185 | } | ||||||||||||||||||||||||||||||||||
| 186 | 0 | $self; | |||||||||||||||||||||||||||||||||
| 187 | } | ||||||||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||||||||
| 189 | =item ($llx, $lly, $urx, $ury) = $page->get_cropbox | ||||||||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||||||||
| 191 | Gets the cropbox based one best estimates or the default. | ||||||||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||||||||
| 193 | =cut | ||||||||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||||||||
| 195 | sub get_cropbox | ||||||||||||||||||||||||||||||||||
| 196 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
get_cropbox: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 197 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||
| 198 | 0 | my $media = [ 0, 0, 612, 792 ]; | |||||||||||||||||||||||||||||||||
| 199 | 0 | foreach my $mediatype (qw[CropBox BleedBox TrimBox ArtBox MediaBox]) | |||||||||||||||||||||||||||||||||
| 200 | { | ||||||||||||||||||||||||||||||||||
| 201 | 0 | my $mediaobj = undef; | |||||||||||||||||||||||||||||||||
| 202 | 0 | ▶ | if($mediaobj = $self->find_prop($mediatype)) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 203 | { | ||||||||||||||||||||||||||||||||||
| 204 | 0 | $media = [ map{ $_->val } $mediaobj->elementsof ]; | |||||||||||||||||||||||||||||||||
| 205 | 0 | last; | |||||||||||||||||||||||||||||||||
| 206 | } | ||||||||||||||||||||||||||||||||||
| 207 | } | ||||||||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||||||||
| 209 | 0 | return(@{$media}); | |||||||||||||||||||||||||||||||||
| 210 | } | ||||||||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||||||||
| 212 | =item $page->bleedbox $w, $h | ||||||||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||||||||
| 214 | =item $page->bleedbox $llx, $lly, $urx, $ury | ||||||||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||||||||
| 216 | =item $page->bleedbox $alias | ||||||||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||||||||
| 218 | Sets the bleedbox. This method supports the same aliases as mediabox. | ||||||||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||||||||
| 220 | =cut | ||||||||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||||||||
| 222 | 0 | ▶ | sub bleedbox { | ||||||||||||||||||||||||||||||||
|
Subroutine
bleedbox: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 223 | 0 | my ($self,$x1,$y1,$x2,$y2) = @_; | |||||||||||||||||||||||||||||||||
| 224 | 0 | ▶ | if(defined $x2) { | ||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||
| 225 | $self->{'BleedBox'}=PDFArray( | ||||||||||||||||||||||||||||||||||
| 226 | 0 | map { PDFNum(float($_)) } ($x1,$y1,$x2,$y2) | |||||||||||||||||||||||||||||||||
| 227 | ); | ||||||||||||||||||||||||||||||||||
| 228 | } elsif(defined $y1) { | ||||||||||||||||||||||||||||||||||
| 229 | $self->{'BleedBox'}=PDFArray( | ||||||||||||||||||||||||||||||||||
| 230 | 0 | map { PDFNum(float($_)) } (0,0,$x1,$y1) | |||||||||||||||||||||||||||||||||
| 231 | ); | ||||||||||||||||||||||||||||||||||
| 232 | } else { | ||||||||||||||||||||||||||||||||||
| 233 | $self->{'BleedBox'}=PDFArray( | ||||||||||||||||||||||||||||||||||
| 234 | 0 | (map { PDFNum(float($_)) } page_size($x1)) | |||||||||||||||||||||||||||||||||
| 235 | ); | ||||||||||||||||||||||||||||||||||
| 236 | } | ||||||||||||||||||||||||||||||||||
| 237 | 0 | $self; | |||||||||||||||||||||||||||||||||
| 238 | } | ||||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||||
| 240 | =item ($llx, $lly, $urx, $ury) = $page->get_bleedbox | ||||||||||||||||||||||||||||||||||
| 241 | |||||||||||||||||||||||||||||||||||
| 242 | Gets the bleedbox based one best estimates or the default. | ||||||||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||||||||
| 244 | =cut | ||||||||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||||||||
| 246 | sub get_bleedbox | ||||||||||||||||||||||||||||||||||
| 247 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
get_bleedbox: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 248 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||
| 249 | 0 | my $media = [ 0, 0, 612, 792 ]; | |||||||||||||||||||||||||||||||||
| 250 | 0 | foreach my $mediatype (qw[BleedBox TrimBox ArtBox MediaBox CropBox]) | |||||||||||||||||||||||||||||||||
| 251 | { | ||||||||||||||||||||||||||||||||||
| 252 | 0 | my $mediaobj = undef; | |||||||||||||||||||||||||||||||||
| 253 | 0 | ▶ | if($mediaobj = $self->find_prop($mediatype)) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 254 | { | ||||||||||||||||||||||||||||||||||
| 255 | 0 | $media = [ map{ $_->val } $mediaobj->elementsof ]; | |||||||||||||||||||||||||||||||||
| 256 | 0 | last; | |||||||||||||||||||||||||||||||||
| 257 | } | ||||||||||||||||||||||||||||||||||
| 258 | } | ||||||||||||||||||||||||||||||||||
| 259 | |||||||||||||||||||||||||||||||||||
| 260 | 0 | return(@{$media}); | |||||||||||||||||||||||||||||||||
| 261 | } | ||||||||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||||||||
| 263 | =item $page->trimbox $w, $h | ||||||||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||||||||
| 265 | =item $page->trimbox $llx, $lly, $urx, $ury | ||||||||||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||||||||
| 267 | Sets the trimbox. This method supports the same aliases as mediabox. | ||||||||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||||||||
| 269 | =cut | ||||||||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||||||||
| 271 | 0 | ▶ | sub trimbox { | ||||||||||||||||||||||||||||||||
|
Subroutine
trimbox: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 272 | 0 | my ($self,$x1,$y1,$x2,$y2) = @_; | |||||||||||||||||||||||||||||||||
| 273 | 0 | ▶ | if(defined $x2) { | ||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||
| 274 | $self->{'TrimBox'}=PDFArray( | ||||||||||||||||||||||||||||||||||
| 275 | 0 | map { PDFNum(float($_)) } ($x1,$y1,$x2,$y2) | |||||||||||||||||||||||||||||||||
| 276 | ); | ||||||||||||||||||||||||||||||||||
| 277 | } elsif(defined $y1) { | ||||||||||||||||||||||||||||||||||
| 278 | $self->{'TrimBox'}=PDFArray( | ||||||||||||||||||||||||||||||||||
| 279 | 0 | map { PDFNum(float($_)) } (0,0,$x1,$y1) | |||||||||||||||||||||||||||||||||
| 280 | ); | ||||||||||||||||||||||||||||||||||
| 281 | } else { | ||||||||||||||||||||||||||||||||||
| 282 | $self->{'TrimBox'}=PDFArray( | ||||||||||||||||||||||||||||||||||
| 283 | 0 | (map { PDFNum(float($_)) } page_size($x1)) | |||||||||||||||||||||||||||||||||
| 284 | ); | ||||||||||||||||||||||||||||||||||
| 285 | } | ||||||||||||||||||||||||||||||||||
| 286 | 0 | $self; | |||||||||||||||||||||||||||||||||
| 287 | } | ||||||||||||||||||||||||||||||||||
| 288 | |||||||||||||||||||||||||||||||||||
| 289 | =item ($llx, $lly, $urx, $ury) = $page->get_trimbox | ||||||||||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||||||||
| 291 | Gets the trimbox based one best estimates or the default. | ||||||||||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||||||||
| 293 | =cut | ||||||||||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||||||||
| 295 | sub get_trimbox | ||||||||||||||||||||||||||||||||||
| 296 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
get_trimbox: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 297 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||
| 298 | 0 | my $media = [ 0, 0, 612, 792 ]; | |||||||||||||||||||||||||||||||||
| 299 | 0 | foreach my $mediatype (qw[TrimBox ArtBox MediaBox CropBox BleedBox]) | |||||||||||||||||||||||||||||||||
| 300 | { | ||||||||||||||||||||||||||||||||||
| 301 | 0 | my $mediaobj = undef; | |||||||||||||||||||||||||||||||||
| 302 | 0 | ▶ | if($mediaobj = $self->find_prop($mediatype)) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 303 | { | ||||||||||||||||||||||||||||||||||
| 304 | 0 | $media = [ map{ $_->val } $mediaobj->elementsof ]; | |||||||||||||||||||||||||||||||||
| 305 | 0 | last; | |||||||||||||||||||||||||||||||||
| 306 | } | ||||||||||||||||||||||||||||||||||
| 307 | } | ||||||||||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||||||||
| 309 | 0 | return(@{$media}); | |||||||||||||||||||||||||||||||||
| 310 | } | ||||||||||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||||||||
| 312 | =item $page->artbox $w, $h | ||||||||||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||||||||
| 314 | =item $page->artbox $llx, $lly, $urx, $ury | ||||||||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||||||||
| 316 | =item $page->artbox $alias | ||||||||||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||||||||
| 318 | Sets the artbox. This method supports the same aliases as mediabox. | ||||||||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||||||||
| 320 | =cut | ||||||||||||||||||||||||||||||||||
| 321 | |||||||||||||||||||||||||||||||||||
| 322 | 0 | ▶ | sub artbox { | ||||||||||||||||||||||||||||||||
|
Subroutine
artbox: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 323 | 0 | my ($self,$x1,$y1,$x2,$y2) = @_; | |||||||||||||||||||||||||||||||||
| 324 | 0 | ▶ | if(defined $x2) { | ||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||
| 325 | $self->{'ArtBox'}=PDFArray( | ||||||||||||||||||||||||||||||||||
| 326 | 0 | map { PDFNum(float($_)) } ($x1,$y1,$x2,$y2) | |||||||||||||||||||||||||||||||||
| 327 | ); | ||||||||||||||||||||||||||||||||||
| 328 | } elsif(defined $y1) { | ||||||||||||||||||||||||||||||||||
| 329 | $self->{'ArtBox'}=PDFArray( | ||||||||||||||||||||||||||||||||||
| 330 | 0 | map { PDFNum(float($_)) } (0,0,$x1,$y1) | |||||||||||||||||||||||||||||||||
| 331 | ); | ||||||||||||||||||||||||||||||||||
| 332 | } else { | ||||||||||||||||||||||||||||||||||
| 333 | $self->{'ArtBox'}=PDFArray( | ||||||||||||||||||||||||||||||||||
| 334 | 0 | (map { PDFNum(float($_)) } page_size($x1)) | |||||||||||||||||||||||||||||||||
| 335 | ); | ||||||||||||||||||||||||||||||||||
| 336 | } | ||||||||||||||||||||||||||||||||||
| 337 | 0 | $self; | |||||||||||||||||||||||||||||||||
| 338 | } | ||||||||||||||||||||||||||||||||||
| 339 | |||||||||||||||||||||||||||||||||||
| 340 | =item ($llx, $lly, $urx, $ury) = $page->get_artbox | ||||||||||||||||||||||||||||||||||
| 341 | |||||||||||||||||||||||||||||||||||
| 342 | Gets the artbox based one best estimates or the default. | ||||||||||||||||||||||||||||||||||
| 343 | |||||||||||||||||||||||||||||||||||
| 344 | =cut | ||||||||||||||||||||||||||||||||||
| 345 | |||||||||||||||||||||||||||||||||||
| 346 | sub get_artbox | ||||||||||||||||||||||||||||||||||
| 347 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
get_artbox: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 348 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||
| 349 | 0 | my $media = [ 0, 0, 612, 792 ]; | |||||||||||||||||||||||||||||||||
| 350 | 0 | foreach my $mediatype (qw[ArtBox TrimBox BleedBox CropBox MediaBox]) | |||||||||||||||||||||||||||||||||
| 351 | { | ||||||||||||||||||||||||||||||||||
| 352 | 0 | my $mediaobj = undef; | |||||||||||||||||||||||||||||||||
| 353 | 0 | ▶ | if($mediaobj = $self->find_prop($mediatype)) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 354 | { | ||||||||||||||||||||||||||||||||||
| 355 | 0 | $media = [ map{ $_->val } $mediaobj->elementsof ]; | |||||||||||||||||||||||||||||||||
| 356 | 0 | last; | |||||||||||||||||||||||||||||||||
| 357 | } | ||||||||||||||||||||||||||||||||||
| 358 | } | ||||||||||||||||||||||||||||||||||
| 359 | |||||||||||||||||||||||||||||||||||
| 360 | 0 | return(@{$media}); | |||||||||||||||||||||||||||||||||
| 361 | } | ||||||||||||||||||||||||||||||||||
| 362 | |||||||||||||||||||||||||||||||||||
| 363 | =item $page->rotate $deg | ||||||||||||||||||||||||||||||||||
| 364 | |||||||||||||||||||||||||||||||||||
| 365 | Rotates the page by the given degrees, which must be a multiple of 90. | ||||||||||||||||||||||||||||||||||
| 366 | |||||||||||||||||||||||||||||||||||
| 367 | (This allows you to auto-rotate to landscape without changing the mediabox!) | ||||||||||||||||||||||||||||||||||
| 368 | |||||||||||||||||||||||||||||||||||
| 369 | =cut | ||||||||||||||||||||||||||||||||||
| 370 | |||||||||||||||||||||||||||||||||||
| 371 | 0 | ▶ | sub rotate { | ||||||||||||||||||||||||||||||||
|
Subroutine
rotate: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 372 | 0 | my ($self,$deg) = @_; | |||||||||||||||||||||||||||||||||
| 373 | 0 | $deg=floor($deg/90); | |||||||||||||||||||||||||||||||||
| 374 | 0 | ▶ | while($deg>4) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 375 | 0 | $deg-=4; | |||||||||||||||||||||||||||||||||
| 376 | } | ||||||||||||||||||||||||||||||||||
| 377 | 0 | ▶ | while($deg<0) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 378 | 0 | $deg+=4; | |||||||||||||||||||||||||||||||||
| 379 | } | ||||||||||||||||||||||||||||||||||
| 380 | 0 | ▶ | if($deg==0) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 381 | 0 | delete $self->{Rotate}; | |||||||||||||||||||||||||||||||||
| 382 | } else { | ||||||||||||||||||||||||||||||||||
| 383 | 0 | $self->{Rotate}=PDFNum($deg*90); | |||||||||||||||||||||||||||||||||
| 384 | } | ||||||||||||||||||||||||||||||||||
| 385 | 0 | return($self); | |||||||||||||||||||||||||||||||||
| 386 | } | ||||||||||||||||||||||||||||||||||
| 387 | |||||||||||||||||||||||||||||||||||
| 388 | =item $gfx = $page->gfx $prepend | ||||||||||||||||||||||||||||||||||
| 389 | |||||||||||||||||||||||||||||||||||
| 390 | Returns a graphics content object. If $prepend is true the content | ||||||||||||||||||||||||||||||||||
| 391 | will be prepended to the page description. | ||||||||||||||||||||||||||||||||||
| 392 | |||||||||||||||||||||||||||||||||||
| 393 | =cut | ||||||||||||||||||||||||||||||||||
| 394 | |||||||||||||||||||||||||||||||||||
| 395 | 0 | ▶ | sub fixcontents { | ||||||||||||||||||||||||||||||||
|
Subroutine
fixcontents: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 396 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||
| 397 | 0 | ▶ | $self->{'Contents'} = $self->{'Contents'} || PDFArray(); | ||||||||||||||||||||||||||||||||
|
Condition0%0/3
$self->{'Contents'} || PDFArray()
MC/DC0%0/2
$self->{'Contents'} || PDFArray()
$self->{'Contents'}
PDFArray()
Truth table0%0/3
A || B
A= $self->{'Contents'}B= PDFArray()
| |||||||||||||||||||||||||||||||||||
| 398 | 0 | ▶ | if(ref($self->{'Contents'})=~/Objind$/) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 399 | 0 | $self->{'Contents'}->realise; | |||||||||||||||||||||||||||||||||
| 400 | } | ||||||||||||||||||||||||||||||||||
| 401 | 0 | ▶ | if(ref($self->{'Contents'})!~/Array$/) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 402 | 0 | $self->{'Contents'} = PDFArray($self->{'Contents'}); | |||||||||||||||||||||||||||||||||
| 403 | } | ||||||||||||||||||||||||||||||||||
| 404 | } | ||||||||||||||||||||||||||||||||||
| 405 | |||||||||||||||||||||||||||||||||||
| 406 | 0 | ▶ | sub content { | ||||||||||||||||||||||||||||||||
|
Subroutine
content: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 407 | 0 | my ($self,$obj,$dir) = @_; | |||||||||||||||||||||||||||||||||
| 408 | 0 | ▶ | if(defined($dir) && $dir>0) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $dir and $dir > 0
MC/DC0%0/2
defined $dir and $dir > 0
defined $dir
$dir > 0
Truth table0%0/3
A and B
A= defined $dirB= $dir > 0
| |||||||||||||||||||||||||||||||||||
| 409 | 0 | $self->precontent($obj); | |||||||||||||||||||||||||||||||||
| 410 | } else { | ||||||||||||||||||||||||||||||||||
| 411 | 0 | $self->addcontent($obj); | |||||||||||||||||||||||||||||||||
| 412 | } | ||||||||||||||||||||||||||||||||||
| 413 | 0 | ▶ | $self->{' apipdf'}->new_obj($obj) unless($obj->is_obj($self->{' apipdf'})); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 414 | 0 | $obj->{' apipdf'}=$self->{' apipdf'}; | |||||||||||||||||||||||||||||||||
| 415 | 0 | $obj->{' api'}=$self->{' api'}; | |||||||||||||||||||||||||||||||||
| 416 | 0 | $obj->{' apipage'}=$self; | |||||||||||||||||||||||||||||||||
| 417 | 0 | return($obj); | |||||||||||||||||||||||||||||||||
| 418 | } | ||||||||||||||||||||||||||||||||||
| 419 | |||||||||||||||||||||||||||||||||||
| 420 | 0 | ▶ | sub addcontent { | ||||||||||||||||||||||||||||||||
|
Subroutine
addcontent: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 421 | 0 | my ($self,@objs) = @_; | |||||||||||||||||||||||||||||||||
| 422 | 0 | $self->fixcontents; | |||||||||||||||||||||||||||||||||
| 423 | 0 | $self->{'Contents'}->add_elements(@objs); | |||||||||||||||||||||||||||||||||
| 424 | } | ||||||||||||||||||||||||||||||||||
| 425 | 0 | ▶ | sub precontent { | ||||||||||||||||||||||||||||||||
|
Subroutine
precontent: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 426 | 0 | my ($self,@objs) = @_; | |||||||||||||||||||||||||||||||||
| 427 | 0 | $self->fixcontents; | |||||||||||||||||||||||||||||||||
| 428 | 0 | unshift(@{$self->{'Contents'}->val},@objs); | |||||||||||||||||||||||||||||||||
| 429 | } | ||||||||||||||||||||||||||||||||||
| 430 | |||||||||||||||||||||||||||||||||||
| 431 | 0 | ▶ | sub gfx { | ||||||||||||||||||||||||||||||||
|
Subroutine
gfx: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 432 | 0 | my ($self,$dir) = @_; | |||||||||||||||||||||||||||||||||
| 433 | 0 | my $gfx=PDF::API3::Compat::API2::Content->new(); | |||||||||||||||||||||||||||||||||
| 434 | 0 | $self->content($gfx,$dir); | |||||||||||||||||||||||||||||||||
| 435 | 0 | ▶ | $gfx->compressFlate() if($self->{' api'}->{forcecompress}); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 436 | 0 | return($gfx); | |||||||||||||||||||||||||||||||||
| 437 | } | ||||||||||||||||||||||||||||||||||
| 438 | |||||||||||||||||||||||||||||||||||
| 439 | =item $txt = $page->text $prepend | ||||||||||||||||||||||||||||||||||
| 440 | |||||||||||||||||||||||||||||||||||
| 441 | Returns a text content object. If $prepend is true the content | ||||||||||||||||||||||||||||||||||
| 442 | will be prepended to the page description. | ||||||||||||||||||||||||||||||||||
| 443 | |||||||||||||||||||||||||||||||||||
| 444 | =cut | ||||||||||||||||||||||||||||||||||
| 445 | |||||||||||||||||||||||||||||||||||
| 446 | 0 | ▶ | sub text { | ||||||||||||||||||||||||||||||||
|
Subroutine
text: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 447 | 0 | my ($self,$dir) = @_; | |||||||||||||||||||||||||||||||||
| 448 | 0 | my $text=PDF::API3::Compat::API2::Content::Text->new(); | |||||||||||||||||||||||||||||||||
| 449 | 0 | $self->content($text,$dir); | |||||||||||||||||||||||||||||||||
| 450 | 0 | ▶ | $text->compressFlate() if($self->{' api'}->{forcecompress}); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 451 | 0 | return($text); | |||||||||||||||||||||||||||||||||
| 452 | } | ||||||||||||||||||||||||||||||||||
| 453 | |||||||||||||||||||||||||||||||||||
| 454 | =item $ant = $page->annotation | ||||||||||||||||||||||||||||||||||
| 455 | |||||||||||||||||||||||||||||||||||
| 456 | Returns a new annotation object. | ||||||||||||||||||||||||||||||||||
| 457 | |||||||||||||||||||||||||||||||||||
| 458 | =cut | ||||||||||||||||||||||||||||||||||
| 459 | |||||||||||||||||||||||||||||||||||
| 460 | 0 | ▶ | sub annotation { | ||||||||||||||||||||||||||||||||
|
Subroutine
annotation: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 461 | 0 | my ($self, $type, $key, $obj) = @_; | |||||||||||||||||||||||||||||||||
| 462 | |||||||||||||||||||||||||||||||||||
| 463 | 0 | ▶ | $self->{'Annots'}||=PDFArray(); | ||||||||||||||||||||||||||||||||
|
Condition0%0/3
$self->{"Annots"} ||= PDFArray()
MC/DC0%0/2
$self->{"Annots"} ||= PDFArray()
$self->{"Annots"}
PDFArray()
Truth table0%0/3
A ||= B
A= $self->{"Annots"}B= PDFArray()
| |||||||||||||||||||||||||||||||||||
| 464 | 0 | ▶ | $self->{'Annots'}->realise if(ref($self->{'Annots'})=~/Objind/); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 465 | 0 | ▶ | if($self->{'Annots'}->is_obj($self->{' apipdf'})) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 466 | { | ||||||||||||||||||||||||||||||||||
| 467 | 0 | $self->{'Annots'}->update(); | |||||||||||||||||||||||||||||||||
| 468 | } | ||||||||||||||||||||||||||||||||||
| 469 | else | ||||||||||||||||||||||||||||||||||
| 470 | { | ||||||||||||||||||||||||||||||||||
| 471 | 0 | $self->update(); | |||||||||||||||||||||||||||||||||
| 472 | } | ||||||||||||||||||||||||||||||||||
| 473 | |||||||||||||||||||||||||||||||||||
| 474 | 0 | my $ant=PDF::API3::Compat::API2::Annotation->new; | |||||||||||||||||||||||||||||||||
| 475 | 0 | $self->{'Annots'}->add_elements($ant); | |||||||||||||||||||||||||||||||||
| 476 | 0 | $self->{' apipdf'}->new_obj($ant); | |||||||||||||||||||||||||||||||||
| 477 | 0 | $ant->{' apipdf'}=$self->{' apipdf'}; | |||||||||||||||||||||||||||||||||
| 478 | 0 | $ant->{' apipage'}=$self; | |||||||||||||||||||||||||||||||||
| 479 | |||||||||||||||||||||||||||||||||||
| 480 | 0 | ▶ | if($self->{'Annots'}->is_obj($self->{' apipdf'})) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 481 | { | ||||||||||||||||||||||||||||||||||
| 482 | 0 | $self->{' apipdf'}->out_obj($self->{'Annots'}); | |||||||||||||||||||||||||||||||||
| 483 | } | ||||||||||||||||||||||||||||||||||
| 484 | |||||||||||||||||||||||||||||||||||
| 485 | 0 | return($ant); | |||||||||||||||||||||||||||||||||
| 486 | } | ||||||||||||||||||||||||||||||||||
| 487 | |||||||||||||||||||||||||||||||||||
| 488 | =item $page->resource $type, $key, $obj | ||||||||||||||||||||||||||||||||||
| 489 | |||||||||||||||||||||||||||||||||||
| 490 | Adds a resource to the page-inheritance tree. | ||||||||||||||||||||||||||||||||||
| 491 | |||||||||||||||||||||||||||||||||||
| 492 | B<Example:> | ||||||||||||||||||||||||||||||||||
| 493 | |||||||||||||||||||||||||||||||||||
| 494 | $co->resource('Font',$fontkey,$fontobj); | ||||||||||||||||||||||||||||||||||
| 495 | $co->resource('XObject',$imagekey,$imageobj); | ||||||||||||||||||||||||||||||||||
| 496 | $co->resource('Shading',$shadekey,$shadeobj); | ||||||||||||||||||||||||||||||||||
| 497 | $co->resource('ColorSpace',$spacekey,$speceobj); | ||||||||||||||||||||||||||||||||||
| 498 | |||||||||||||||||||||||||||||||||||
| 499 | B<Note:> You only have to add the required resources, if | ||||||||||||||||||||||||||||||||||
| 500 | they are NOT handled by the *font*, *image*, *shade* or *space* | ||||||||||||||||||||||||||||||||||
| 501 | methods. | ||||||||||||||||||||||||||||||||||
| 502 | |||||||||||||||||||||||||||||||||||
| 503 | =cut | ||||||||||||||||||||||||||||||||||
| 504 | |||||||||||||||||||||||||||||||||||
| 505 | 0 | ▶ | sub resource { | ||||||||||||||||||||||||||||||||
|
Subroutine
resource: not called CC=13 SCAR=52.0
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 506 | 0 | my ($self, $type, $key, $obj, $force) = @_; | |||||||||||||||||||||||||||||||||
| 507 | 0 | my ($dict) = $self->find_prop('Resources'); | |||||||||||||||||||||||||||||||||
| 508 | |||||||||||||||||||||||||||||||||||
| 509 | 0 | ▶ | $dict = $dict || $self->{Resources} || PDFDict(); | ||||||||||||||||||||||||||||||||
|
Condition0%0/6
$dict || $self->{'Resources'} || PDFDict()
$dict or $self->{"Resources"}
MC/DC0%0/3
$dict || $self->{'Resources'} || PDFDict()
$dict
$self->{"Resources"}
PDFDict()
Truth table0%0/4
A or B || C
A= $dictB= $self->{"Resources"}C= PDFDict()
| |||||||||||||||||||||||||||||||||||
| 510 | |||||||||||||||||||||||||||||||||||
| 511 | 0 | ▶ | $dict->realise if(ref($dict)=~/Objind$/); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 512 | |||||||||||||||||||||||||||||||||||
| 513 | 0 | ▶ | $dict->{$type} = $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()
| |||||||||||||||||||||||||||||||||||
| 514 | 0 | ▶ | $dict->{$type}->realise if(ref($dict->{$type})=~/Objind$/); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 515 | |||||||||||||||||||||||||||||||||||
| 516 | 0 | ▶ | unless(defined $obj) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 517 | 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}
| |||||||||||||||||||||||||||||||||||
| 518 | } else { | ||||||||||||||||||||||||||||||||||
| 519 | 0 | ▶ | if($force) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 520 | 0 | $dict->{$type}->{$key} = $obj; | |||||||||||||||||||||||||||||||||
| 521 | } else { | ||||||||||||||||||||||||||||||||||
| 522 | 0 | ▶ | $dict->{$type}->{$key} = $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
| |||||||||||||||||||||||||||||||||||
| 523 | } | ||||||||||||||||||||||||||||||||||
| 524 | |||||||||||||||||||||||||||||||||||
| 525 | 0 | ▶ | $self->{' apipdf'}->out_obj($dict) if($dict->is_obj($self->{' apipdf'})); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 526 | 0 | ▶ | $self->{' apipdf'}->out_obj($dict->{$type}) if($dict->{$type}->is_obj($self->{' apipdf'})); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 527 | 0 | ▶ | $self->{' apipdf'}->out_obj($obj) if($obj->is_obj($self->{' apipdf'})); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 528 | 0 | $self->{' apipdf'}->out_obj($self); | |||||||||||||||||||||||||||||||||
| 529 | |||||||||||||||||||||||||||||||||||
| 530 | 0 | return($dict); | |||||||||||||||||||||||||||||||||
| 531 | } | ||||||||||||||||||||||||||||||||||
| 532 | } | ||||||||||||||||||||||||||||||||||
| 533 | |||||||||||||||||||||||||||||||||||
| 534 | sub ship_out | ||||||||||||||||||||||||||||||||||
| 535 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
ship_out: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 536 | 0 | my ($self, $pdf) = @_; | |||||||||||||||||||||||||||||||||
| 537 | |||||||||||||||||||||||||||||||||||
| 538 | 0 | $pdf->ship_out($self); | |||||||||||||||||||||||||||||||||
| 539 | 0 | ▶ | if (defined $self->{'Contents'}) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 540 | 0 | { $pdf->ship_out($self->{'Contents'}->elementsof); } | |||||||||||||||||||||||||||||||||
| 541 | 0 | $self; | |||||||||||||||||||||||||||||||||
| 542 | } | ||||||||||||||||||||||||||||||||||
| 543 | |||||||||||||||||||||||||||||||||||
| 544 | 0 | ▶ | sub outobjdeep { | ||||||||||||||||||||||||||||||||
|
Subroutine
outobjdeep: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 545 | 0 | my ($self, @opts) = @_; | |||||||||||||||||||||||||||||||||
| 546 | 0 | foreach my $k (qw/ api apipdf /) { | |||||||||||||||||||||||||||||||||
| 547 | 0 | $self->{" $k"}=undef; | |||||||||||||||||||||||||||||||||
| 548 | 0 | delete($self->{" $k"}); | |||||||||||||||||||||||||||||||||
| 549 | } | ||||||||||||||||||||||||||||||||||
| 550 | 0 | $self->SUPER::outobjdeep(@opts); | |||||||||||||||||||||||||||||||||
| 551 | } | ||||||||||||||||||||||||||||||||||
| 552 | |||||||||||||||||||||||||||||||||||
| 553 | 1 | 1; | |||||||||||||||||||||||||||||||||
| 554 | |||||||||||||||||||||||||||||||||||
| 555 | __END__ | ||||||||||||||||||||||||||||||||||