Branch Coverage

blib/lib/PDF/API2.pm
Criterion Covered Total %
branch 219 582 37.6


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 27 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
555 0 1 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
570 1 0 if (defined $month)
571 0 1 unless $month >= 1 and $month <= 12
573 1 0 if (defined $day)
574 0 1 unless $day >= 1 and $day <= 31
576 1 0 if (defined $hour)
577 0 1 unless $hour <= 23
579 1 0 if (defined $minute)
580 0 1 unless $minute <= 59
582 1 0 if (defined $second)
583 0 1 unless $second <= 59
585 1 0 if (defined $od)
586 0 1 if $od eq "Z" and defined $oh
588 0 1 if (defined $oh)
589 0 0 unless $oh <= 23
591 0 1 if (defined $om)
592 0 0 unless $om <= 59
622 0 170 unless (defined $field)
623 0 0 unless exists $self->{'pdf'}{'Info'}
627 0 0 if $key =~ /^ /
628 0 0 unless defined $self->{'pdf'}{'Info'}{$key}
635 167 3 if (@_)
637 0 167 if defined $value and not length $value
639 1 166 if ($field eq "CreationDate" or $field eq "ModDate")
640 1 0 if (defined $value)
641 0 1 unless $value =~ /^D:/
642 0 1 unless _is_date($value)
646 3 164 if (exists $self->{'pdf'}{'Info'}) { }
647 0 164 unless defined $value
655 166 1 if (defined $value) { }
666 0 3 unless $self->{'pdf'}{'Info'}
668 1 2 unless $self->{'pdf'}{'Info'}{$field}
676 0 3 if (not defined $self->{'pdf'}{'Info'}) { }
686 3 0 if (scalar @_)
688 23 1 unless defined $opt{$k}
694 3 0 if (defined $self->{'pdf'}{'Info'})
697 21 3 unless defined $self->{'pdf'}{'Info'}{$k}
699 0 3 if (unpack("n", $opt{$k}) == 65534 or unpack("n", $opt{$k}) == 65279)
714 0 0 if (scalar @attr)
734 0 0 if (@_)
746 0 0 if (not defined $self->{'catalog'}{'Metadata'}) { }
761 0 0 if (defined $value)
798 0 0 defined $self->{'pdf'}{'Encrypt'} ? :
822 1 3 if ($obj) { }
832 3 0 unless $obj->is_obj($self->{'pdf'})
856 1 1 unless ref $page
907 0 169 unless (@_)
908 0 0 unless $self->{'catalog'}{'PageLayout'}
910 0 0 if $layout eq "SinglePage"
911 0 0 if $layout eq "OneColumn"
912 0 0 if $layout eq "TwoColumnLeft"
913 0 0 if $layout eq "TwoColumnRight"
914 0 0 if $layout eq "TwoPageLeft"
915 0 0 if $layout eq "TwoPageRight"
921 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' ? :
928 0 169 unless $layout
981 0 169 unless (@_)
982 0 0 unless $self->{'catalog'}{'PageMode'}
984 0 0 if $mode eq "UseNone"
985 0 0 if $mode eq "UseOutlines"
986 0 0 if $mode eq "UseThumbs"
987 0 0 if $mode eq "FullScreen"
988 0 0 if $mode eq "UseOC"
989 0 0 if $mode eq "UseAttachments"
995 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' ? :
1002 0 169 unless $mode
1025 0 172 unless (@_)
1036 0 169 if ($options{'-fullscreen'}) { }
0 169 elsif ($options{'-thumbs'}) { }
0 169 elsif ($options{'-outlines'}) { }
1050 0 169 if ($options{'-singlepage'}) { }
0 169 elsif ($options{'-onecolumn'}) { }
0 169 elsif ($options{'-twocolumnleft'}) { }
0 169 elsif ($options{'-twocolumnright'}) { }
1067 0 169 if ($options{'-hidetoolbar'})
1070 0 169 if ($options{'-hidemenubar'})
1073 0 169 if ($options{'-hidewindowui'})
1076 0 169 if ($options{'-fitwindow'})
1079 0 169 if ($options{'-centerwindow'})
1082 0 169 if ($options{'-displaytitle'})
1085 0 169 if ($options{'-righttoleft'})
1089 0 169 if ($options{'-afterfullscreenthumbs'}) { }
0 169 elsif ($options{'-afterfullscreenoutlines'}) { }
1099 0 169 if ($options{'-printscalingnone'})
1103 1 168 if ($options{'-simplex'}) { }
1 167 elsif ($options{'-duplexfliplongedge'}) { }
1 166 elsif ($options{'-duplexflipshortedge'}) { }
1114 2 167 if ($options{'-firstpage'})
1116 0 2 unless keys %args
1118 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'}) { }
1151 16 0 if (defined $object->{'Resources'})
1161 0 18 if ($page->{'Type'}->val eq 'Pages') { }
1167 18 0 if (defined $page->{'Resources'})
1202 140 2 if ($index == 0) { }
1214 140 2 if ($index == 0) { }
0 2 elsif ($index < 0) { }
1248 0 6 if ($index == 0) { }
0 6 elsif ($index < 0) { }
1257 0 6 unless ref $page
1259 5 1 if (ref $page ne "PDF::API2::Page")
1266 0 5 if ($rotate = $page->find_prop('Rotate') and not $page->{' opened'}) { }
1269 0 0 if ($rotate != 0 and not $self->default('nounrotate')) { }
1272 0 0 if ($media = $page->find_prop($mediatype)) { }
1277 0 0 if $mediatype ne "MediaBox"
1279 0 0 if ($rotate == 90) { }
0 0 elsif ($rotate == 180) { }
0 0 elsif ($rotate == 270) { }
1280 0 0 if $mediatype eq "MediaBox"
1284 0 0 if $mediatype eq "MediaBox"
1287 0 0 if $mediatype eq "MediaBox"
1301 3 2 if (defined $page->{'Contents'} and not $page->{' opened'})
1307 0 3 if ($self->default("pageencaps"))
1314 0 3 if ($self->default("pageencaps"))
1319 3 0 if ($self->{'forcecompress'})
1375 0 1 unless (ref $s_pdf and $s_pdf->isa("PDF::API2"))
1379 0 1 if (ref $s_idx eq 'PDF::API2::Page') { }
1384 0 1 unless defined $s_page
1387 0 1 if (ref $t_idx eq 'PDF::API2::Page') { }
1391 0 1 if ($self->pages < $t_idx) { }
1410 5 0 unless defined $prop
1421 0 0 if (exists $s_page->{'Annots'} and $s_page->{'Annots'} and $self->{'copyannots'})
1424 0 0 if (my $a = $s_pdf->{'pdf'}{'Root'}->realise->{'AcroForm'})
1457 0 0 if $AcroForm
1473 0 0 unless defined $a->{$k}
1479 0 0 if $AcroForm and $t_a->{'Subtype'}->val eq "Widget"
1482 0 0 if $AcroForm
1531 0 4 unless (ref $s_pdf and $s_pdf->isa("PDF::API2"))
1539 1 3 if (ref $s_idx eq 'PDF::API2::Page') { }
1553 10 2 unless defined $s_page->find_prop($k)
1558 2 2 unless defined $xo->{'BBox'}
1562 0 4 unless defined $s_page->{$k}
1563 0 4 if ref($s_page->{$k}) =~ /Objind$/
1566 27 5 unless defined $s_page->{$k}{$sk}
1567 0 5 if ref($s_page->{$k}{$sk}) =~ /Objind$/
1569 9 1 if $ssk =~ /^ /
1579 0 4 unless ($s_page->{' opened'})
1585 3 1 if (defined $s_page->{'Contents'})
1592 3 0 if ($k->{' nofilt'}) { }
1601 3 0 if $self->{'forcecompress'}
1611 1 15 if (ref($source_object) =~ /Objind$/)
1615 0 16 if defined $$object_cache{scalar $source_object}
1621 1 15 if $source_object->is_obj($source_pdf)
1625 2 14 if (ref($source_object) =~ /Array$/) { }
1 13 elsif (ref($source_object) =~ /Dict$/) { }
1628 0 8 if ref($k) =~ /Objind$/
1633 1 0 unless scalar @keys
1635 1 5 if $k =~ /^ /
1636 0 5 unless defined $source_object->{$k}
1639 0 1 if ($source_object->{' stream'})
1640 0 0 if ($target_object->{'Filter'}) { }
1725 1 7 if (exists $options{'-prefix'})
1728 1 7 if (exists $options{'-start'})
1731 6 2 if (exists $options{'-style'})
1733 1 5 unless ($options{'style'} =~ /^(?:[Rr]oman|[Aa]lpha|decimal)$/)
1767 8 0 if (exists $options{'style'})
1768 0 8 unless ($options{'style'} and $options{'style'} =~ /^([rad])/i)
1771 2 6 $1 eq 'd' ? :
1774 1 7 if (exists $options{'prefix'})
1778 1 7 if (exists $options{'start'})
1807 1 0 if (@_)
1838 6 11 unless (scalar @_)
1839 1 5 unless ($self->{'pages'}{$type})
1840 1 0 if $type eq "MediaBox"
1843 0 0 if $type eq "CropBox"
1861 2 3 unless @_
1868 0 1 unless @_
1875 0 1 unless @_
1882 0 1 unless @_
1889 0 1 unless @_
1967 0 1 if (exists $options{'kerning'})
1972 1 0 if ("PDF::API2::Resource::Font::CoreFont"->is_standard($name))
1977 0 0 $name =~ /\.bdf$/i ? :
0 0 $name =~ /\.pf[ab]$/i ? :
0 0 $name =~ /\.[ot]tf$/i ? :
1981 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 =~ /(\..*)$/) { }
1986 0 0 if (exists $options{'afm_file'})
1989 0 0 if (exists $options{'pfm_file'})
2027 0 0 unless exists $opts{'-unicodemap'}
2033 0 0 if $opts{'-unicodemap'}
2067 0 0 if ref $_[0]
2068 0 0 if $_[0] eq "PDF::API2"
2088 0 38 if ref $_[0]
2089 38 0 if $_[0] eq "PDF::API2"
2100 0 0 if -f $font
2104 0 0 if -f "$directory/$font"
2115 0 53 if $opts{'-unicodemap'}
2123 0 0 unless defined $opts{$o}
2126 0 0 unless $psf = _find_font($psf)
2131 0 0 if $opts{'-unicodemap'}
2143 0 0 unless exists $opts{'-unicodemap'}
2146 0 0 if ($opts{'-noembed'})
2151 0 0 unless my $file = _find_font($name)
2156 0 0 if $opts{'-unicodemap'}
2182 0 1 if $opts{'-unicodemap'}
2240 0 3 if (ref $file eq 'GD::Image') { }
3 0 elsif (ref $file) { }
2246 0 3 unless (ref $file)
2247 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 ? :
2254 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 =~ /(\..*)$/) { }
2291 0 3 unless $bytes_read and $bytes_read == 8
2293 1 2 if $test =~ /^GIF\d\d[a-z]/
2294 1 1 if $test =~ /^\xFF\xD8\xFF/
2295 1 0 if $test =~ /^\x89PNG\x0D\x0A\x1A\x0A/
2460 0 0 unless defined $format
2461 0 0 unless defined $value
2464 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') { }
2468 0 0 if ($options{'bar_extend'})
2480 0 0 if ($options{'bar_extend'})
2493 0 0 if ($options{'bar_extend'})
2501 0 0 unless ($options{'caption'})
2504 0 0 if ($options{'bar_extend'})
2517 0 0 if (exists $options{'caption'})
2520 0 0 if ($options{'bar_extend'} or $options{'font_size'})
2534 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') { }
2716 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') { }
2811 2 6 if (defined $value)
2857 0 0 unless (defined $obj)