Branch Coverage

blib/lib/PDF/API2.pm
Criterion Covered Total %
branch 239 590 40.5


line true false branch
111 164 0 unless $self->{'pages'}{'Resources'}->is_obj($self->{'pdf'})
118 27 137 if (exists $options{'-compress'})
122 114 50 if (exists $options{'compress'}) { }
123 0 114 $options{'compress'} ? :
131 0 164 if $options{'-file'}
133 0 164 if ($options{'file'})
169 0 8 unless -f $file
170 0 8 unless -r $file
182 0 8 unless $is_writable
205 2 14 if (exists $options{'-compress'})
209 2 14 if (exists $options{'compress'}) { }
210 0 2 $options{'compress'} ? :
238 0 1 if ($self->{'partial_save'} and not $file) { }
0 1 elsif ($self->{'opened_scalar'}) { }
242 0 0 unless $file
245 0 0 unless CORE::open $fh, ">", $file
251 0 1 unless $file
252 1 0 do { $self->{'pdf'}{' fname'} eq $file } ? :
1 0 $self->{'pdf'}{' fname'} ? :
256 0 1 if $self->{'opened_readonly'}
281 0 0 if ($self->{'partial_save'})
291 0 0 if $self->{'opened_readonly'}
317 275 23 if defined $self->{'pdf'}
361 0 8 unless CORE::open $fh, "+<", \$content
397 3 144 if ($self->{'opened_scalar'}) { }
4 140 elsif ($self->{'opened'}) { }
403 0 4 unless CORE::open $fh, ">", \$string
410 0 140 unless CORE::open $fh, ">", \$string
560 10 22 unless $value =~ /^D:([0-9]{4}) # D:YYYY (required) (?:([01][0-9]) # Month (01-12) (?:([0123][0-9]) # Day (01-31) (?:([012][0-9]) # Hour (00-23) (?:([012345][0-9]) # Minute (00-59) (?:([012345][0-9]) # Second (00-59) (?:([Z+-]) # UT Offset Direction (?:([012][0-9])\'? # UT Offset Hours (?:([012345][0-9])\'? # UT Offset Minutes )?)?)?)?)?)?)?)?$/x
575 21 1 if (defined $month)
576 1 20 unless $month >= 1 and $month <= 12
578 19 2 if (defined $day)
579 1 18 unless $day >= 1 and $day <= 31
581 17 3 if (defined $hour)
582 1 16 unless $hour <= 23
584 15 4 if (defined $minute)
585 0 15 unless $minute <= 59
587 14 5 if (defined $second)
588 0 14 unless $second <= 59
590 13 6 if (defined $od)
591 0 13 if $od eq "Z" and defined $oh
593 11 8 if (defined $oh)
594 2 9 unless $oh <= 23
596 6 11 if (defined $om)
597 0 6 unless $om <= 59
599 6 11 if (defined $oh and $om)
601 2 4 unless $value =~ /$oh\'$om\'?/
631 0 170 unless (defined $field)
632 0 0 unless exists $self->{'pdf'}{'Info'}
636 0 0 if $key =~ /^ /
637 0 0 unless defined $self->{'pdf'}{'Info'}{$key}
644 167 3 if (@_)
646 0 167 if defined $value and not length $value
648 1 166 if ($field eq "CreationDate" or $field eq "ModDate")
649 1 0 if (defined $value)
650 0 1 unless $value =~ /^D:/
651 0 1 unless _is_date($value)
655 3 164 if (exists $self->{'pdf'}{'Info'}) { }
656 0 164 unless defined $value
664 166 1 if (defined $value) { }
675 0 3 unless $self->{'pdf'}{'Info'}
677 1 2 unless $self->{'pdf'}{'Info'}{$field}
685 0 3 if (not defined $self->{'pdf'}{'Info'}) { }
695 3 0 if (scalar @_)
697 23 1 unless defined $opt{$k}
703 3 0 if (defined $self->{'pdf'}{'Info'})
706 21 3 unless defined $self->{'pdf'}{'Info'}{$k}
708 0 3 if (unpack("n", $opt{$k}) == 65534 or unpack("n", $opt{$k}) == 65279)
723 0 0 if (scalar @attr)
743 0 0 if (@_)
755 0 0 if (not defined $self->{'catalog'}{'Metadata'}) { }
770 0 0 if (defined $value)
807 0 0 defined $self->{'pdf'}{'Encrypt'} ? :
831 1 3 if ($obj) { }
841 3 0 unless $obj->is_obj($self->{'pdf'})
865 1 1 unless ref $page
916 0 169 unless (@_)
917 0 0 unless $self->{'catalog'}{'PageLayout'}
919 0 0 if $layout eq "SinglePage"
920 0 0 if $layout eq "OneColumn"
921 0 0 if $layout eq "TwoColumnLeft"
922 0 0 if $layout eq "TwoColumnRight"
923 0 0 if $layout eq "TwoPageLeft"
924 0 0 if $layout eq "TwoPageRight"
930 0 0 $name eq 'two_page_right' ? :
0 0 $name eq 'two_page_left' ? :
0 0 $name eq 'two_column_right' ? :
0 0 $name eq 'two_column_left' ? :
0 0 $name eq 'one_column' ? :
169 0 $name eq 'single_page' ? :
937 0 169 unless $layout
990 0 169 unless (@_)
991 0 0 unless $self->{'catalog'}{'PageMode'}
993 0 0 if $mode eq "UseNone"
994 0 0 if $mode eq "UseOutlines"
995 0 0 if $mode eq "UseThumbs"
996 0 0 if $mode eq "FullScreen"
997 0 0 if $mode eq "UseOC"
998 0 0 if $mode eq "UseAttachments"
1004 0 0 $name eq 'attachments' ? :
0 0 $name eq 'optional_content' ? :
0 0 $name eq 'full_screen' ? :
0 0 $name eq 'thumbnails' ? :
0 0 $name eq 'outlines' ? :
169 0 $name eq 'none' ? :
1011 0 169 unless $mode
1034 0 172 unless (@_)
1045 0 169 if ($options{'-fullscreen'}) { }
0 169 elsif ($options{'-thumbs'}) { }
0 169 elsif ($options{'-outlines'}) { }
1059 0 169 if ($options{'-singlepage'}) { }
0 169 elsif ($options{'-onecolumn'}) { }
0 169 elsif ($options{'-twocolumnleft'}) { }
0 169 elsif ($options{'-twocolumnright'}) { }
1076 0 169 if ($options{'-hidetoolbar'})
1079 0 169 if ($options{'-hidemenubar'})
1082 0 169 if ($options{'-hidewindowui'})
1085 0 169 if ($options{'-fitwindow'})
1088 0 169 if ($options{'-centerwindow'})
1091 0 169 if ($options{'-displaytitle'})
1094 0 169 if ($options{'-righttoleft'})
1098 0 169 if ($options{'-afterfullscreenthumbs'}) { }
0 169 elsif ($options{'-afterfullscreenoutlines'}) { }
1108 0 169 if ($options{'-printscalingnone'})
1112 1 168 if ($options{'-simplex'}) { }
1 167 elsif ($options{'-duplexfliplongedge'}) { }
1 166 elsif ($options{'-duplexflipshortedge'}) { }
1123 2 167 if ($options{'-firstpage'})
1125 0 2 unless keys %args
1127 2 0 if (defined $args{'-fit'}) { }
0 0 elsif (defined $args{'-fith'}) { }
0 0 elsif (defined $args{'-fitb'}) { }
0 0 elsif (defined $args{'-fitbh'}) { }
0 0 elsif (defined $args{'-fitv'}) { }
0 0 elsif (defined $args{'-fitbv'}) { }
0 0 elsif (defined $args{'-fitr'}) { }
0 0 elsif (defined $args{'-xyz'}) { }
1160 16 0 if (defined $object->{'Resources'})
1170 0 18 if ($page->{'Type'}->val eq 'Pages') { }
1176 18 0 if (defined $page->{'Resources'})
1211 140 2 if ($index == 0) { }
1223 140 2 if ($index == 0) { }
0 2 elsif ($index < 0) { }
1257 0 6 if ($index == 0) { }
0 6 elsif ($index < 0) { }
1266 0 6 unless ref $page
1268 5 1 if (ref $page ne "PDF::API2::Page")
1275 0 5 if ($rotate = $page->find_prop('Rotate') and not $page->{' opened'}) { }
1278 0 0 if ($rotate != 0 and not $self->default('nounrotate')) { }
1281 0 0 if ($media = $page->find_prop($mediatype)) { }
1286 0 0 if $mediatype ne "MediaBox"
1288 0 0 if ($rotate == 90) { }
0 0 elsif ($rotate == 180) { }
0 0 elsif ($rotate == 270) { }
1289 0 0 if $mediatype eq "MediaBox"
1293 0 0 if $mediatype eq "MediaBox"
1296 0 0 if $mediatype eq "MediaBox"
1310 3 2 if (defined $page->{'Contents'} and not $page->{' opened'})
1316 0 3 if ($self->default("pageencaps"))
1323 0 3 if ($self->default("pageencaps"))
1328 3 0 if ($self->{'forcecompress'})
1384 0 1 unless (ref $s_pdf and $s_pdf->isa("PDF::API2"))
1388 0 1 if (ref $s_idx eq 'PDF::API2::Page') { }
1393 0 1 unless defined $s_page
1396 0 1 if (ref $t_idx eq 'PDF::API2::Page') { }
1400 0 1 if ($self->pages < $t_idx) { }
1419 5 0 unless defined $prop
1430 0 0 if (exists $s_page->{'Annots'} and $s_page->{'Annots'} and $self->{'copyannots'})
1433 0 0 if (my $a = $s_pdf->{'pdf'}{'Root'}->realise->{'AcroForm'})
1466 0 0 if $AcroForm
1482 0 0 unless defined $a->{$k}
1488 0 0 if $AcroForm and $t_a->{'Subtype'}->val eq "Widget"
1491 0 0 if $AcroForm
1540 0 4 unless (ref $s_pdf and $s_pdf->isa("PDF::API2"))
1548 1 3 if (ref $s_idx eq 'PDF::API2::Page') { }
1553 0 3 unless defined $s_page
1563 10 2 unless defined $s_page->find_prop($k)
1568 2 2 unless defined $xo->{'BBox'}
1572 0 4 unless defined $s_page->{$k}
1573 0 4 if ref($s_page->{$k}) =~ /Objind$/
1576 27 5 unless defined $s_page->{$k}{$sk}
1577 0 5 if ref($s_page->{$k}{$sk}) =~ /Objind$/
1579 9 1 if $ssk =~ /^ /
1589 0 4 unless ($s_page->{' opened'})
1595 3 1 if (defined $s_page->{'Contents'})
1602 3 0 if ($k->{' nofilt'}) { }
1611 3 0 if $self->{'forcecompress'}
1621 1 15 if (ref($source_object) =~ /Objind$/)
1625 0 16 if defined $$object_cache{scalar $source_object}
1631 1 15 if $source_object->is_obj($source_pdf)
1635 2 14 if (ref($source_object) =~ /Array$/) { }
1 13 elsif (ref($source_object) =~ /Dict$/) { }
1638 0 8 if ref($k) =~ /Objind$/
1643 1 0 unless scalar @keys
1645 1 5 if $k =~ /^ /
1646 0 5 unless defined $source_object->{$k}
1649 0 1 if ($source_object->{' stream'})
1650 0 0 if ($target_object->{'Filter'}) { }
1735 1 7 if (exists $options{'-prefix'})
1738 1 7 if (exists $options{'-start'})
1741 6 2 if (exists $options{'-style'})
1743 1 5 unless ($options{'style'} =~ /^(?:[Rr]oman|[Aa]lpha|decimal)$/)
1777 8 0 if (exists $options{'style'})
1778 0 8 unless ($options{'style'} and $options{'style'} =~ /^([rad])/i)
1781 2 6 $1 eq 'd' ? :
1784 1 7 if (exists $options{'prefix'})
1788 1 7 if (exists $options{'start'})
1817 1 0 if (@_)
1848 6 11 unless (scalar @_)
1849 1 5 unless ($self->{'pages'}{$type})
1850 1 0 if $type eq "MediaBox"
1853 0 0 if $type eq "CropBox"
1871 2 3 unless @_
1878 0 1 unless @_
1885 0 1 unless @_
1892 0 1 unless @_
1899 0 1 unless @_
1977 0 1 if (exists $options{'kerning'})
1982 1 0 if ('PDF::API2::Resource::Font::CoreFont'->is_standard($name)) { }
0 0 elsif ($name eq 'Times' and not $options{'format'}) { }
1993 0 0 $name =~ /\.bdf$/i ? :
0 0 $name =~ /\.pf[ab]$/i ? :
0 0 $name =~ /\.[ot]tf$/i ? :
1997 0 0 if ($format eq 'truetype') { }
0 0 elsif ($format eq 'type1') { }
0 0 elsif ($format eq 'bitmap') { }
0 0 elsif ($format) { }
0 0 elsif ($name =~ /(\..*)$/) { }
2002 0 0 if (exists $options{'afm_file'})
2005 0 0 if (exists $options{'pfm_file'})
2043 0 0 unless exists $opts{'-unicodemap'}
2049 0 0 if $opts{'-unicodemap'}
2083 0 0 if ref $_[0]
2084 0 0 if $_[0] eq "PDF::API2"
2104 0 39 if ref $_[0]
2105 39 0 if $_[0] eq "PDF::API2"
2116 0 0 if -f $font
2120 0 0 if -f "$directory/$font"
2131 0 53 if $opts{'-unicodemap'}
2139 0 0 unless defined $opts{$o}
2142 0 0 unless $psf = _find_font($psf)
2147 0 0 if $opts{'-unicodemap'}
2159 0 0 unless exists $opts{'-unicodemap'}
2162 0 0 if ($opts{'-noembed'})
2167 0 0 unless my $file = _find_font($name)
2172 0 0 if $opts{'-unicodemap'}
2198 0 1 if $opts{'-unicodemap'}
2256 0 3 if (ref $file eq 'GD::Image') { }
3 0 elsif (ref $file) { }
2262 0 3 unless (ref $file)
2263 0 0 $file =~ /\.p[bgp]m$/i ? :
0 0 $file =~ /\.tiff?$/i ? :
0 0 $file =~ /\.gif$/i ? :
0 0 $file =~ /\.png$/i ? :
0 0 $file =~ /\.jpe?g$/i ? :
2270 1 2 if ($format eq 'jpeg') { }
1 1 elsif ($format eq 'png') { }
1 0 elsif ($format eq 'gif') { }
0 0 elsif ($format eq 'tiff') { }
0 0 elsif ($format eq 'pnm') { }
0 0 elsif ($format) { }
0 0 elsif (ref $file) { }
0 0 elsif ($file =~ /(\..*)$/) { }
2307 0 3 unless $bytes_read and $bytes_read == 8
2309 1 2 if $test =~ /^GIF\d\d[a-z]/
2310 1 1 if $test =~ /^\xFF\xD8\xFF/
2311 1 0 if $test =~ /^\x89PNG\x0D\x0A\x1A\x0A/
2481 0 0 unless defined $format
2482 0 0 unless defined $value
2485 0 0 if ($format eq 'codabar') { }
0 0 elsif ($format eq 'code128' or $format eq 'ean128' or $format eq 'code39') { }
0 0 elsif ($format eq 'itf') { }
0 0 elsif ($format eq 'ean13') { }
0 0 elsif ($format eq 'qr') { }
2489 0 0 if ($options{'bar_extend'})
2501 0 0 if ($options{'bar_extend'})
2514 0 0 if ($options{'bar_extend'})
2522 0 0 unless ($options{'caption'})
2525 0 0 if ($options{'bar_extend'})
2538 0 0 if (exists $options{'caption'})
2541 0 0 if ($options{'bar_extend'} or $options{'font_size'})
2555 0 0 if ($format eq 'codabar') { }
0 0 elsif ($format eq 'code128') { }
0 0 elsif ($format eq 'code39') { }
0 0 elsif ($format eq 'ean128') { }
0 0 elsif ($format eq 'ean13') { }
0 0 elsif ($format eq 'itf') { }
0 0 elsif ($format eq 'qr') { }
2737 0 0 if ($type eq 'act') { }
0 0 elsif ($type eq 'web') { }
0 0 elsif ($type eq 'hue') { }
0 0 elsif ($type eq 'spot') { }
0 0 elsif ($type eq 'device') { }
2832 2 6 if (defined $value)
2878 0 0 unless (defined $obj)