Branch Coverage

blib/lib/PDF/API2.pm
Criterion Covered Total %
branch 218 576 37.8


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 274 35 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') { }
1386 0 1 if (ref $t_idx eq 'PDF::API2::Page') { }
1390 0 1 if ($self->pages < $t_idx) { }
1409 5 0 unless defined $prop
1420 0 0 if (exists $s_page->{'Annots'} and $s_page->{'Annots'} and $self->{'copyannots'})
1423 0 0 if (my $a = $s_pdf->{'pdf'}{'Root'}->realise->{'AcroForm'})
1456 0 0 if $AcroForm
1472 0 0 unless defined $a->{$k}
1478 0 0 if $AcroForm and $t_a->{'Subtype'}->val eq "Widget"
1481 0 0 if $AcroForm
1530 0 4 unless (ref $s_pdf and $s_pdf->isa("PDF::API2"))
1538 1 3 if (ref $s_idx eq 'PDF::API2::Page') { }
1552 10 2 unless defined $s_page->find_prop($k)
1557 2 2 unless defined $xo->{'BBox'}
1561 0 4 unless defined $s_page->{$k}
1562 0 4 if ref($s_page->{$k}) =~ /Objind$/
1565 27 5 unless defined $s_page->{$k}{$sk}
1566 0 5 if ref($s_page->{$k}{$sk}) =~ /Objind$/
1568 9 1 if $ssk =~ /^ /
1578 0 4 unless ($s_page->{' opened'})
1584 3 1 if (defined $s_page->{'Contents'})
1591 3 0 if ($k->{' nofilt'}) { }
1600 3 0 if $self->{'forcecompress'}
1610 1 15 if (ref($source_object) =~ /Objind$/)
1614 0 16 if defined $$object_cache{scalar $source_object}
1620 1 15 if $source_object->is_obj($source_pdf)
1624 2 14 if (ref($source_object) =~ /Array$/) { }
1 13 elsif (ref($source_object) =~ /Dict$/) { }
1627 0 8 if ref($k) =~ /Objind$/
1632 1 0 unless scalar @keys
1634 1 5 if $k =~ /^ /
1635 0 5 unless defined $source_object->{$k}
1638 0 1 if ($source_object->{' stream'})
1639 0 0 if ($target_object->{'Filter'}) { }
1724 1 7 if (exists $options{'-prefix'})
1727 1 7 if (exists $options{'-start'})
1730 6 2 if (exists $options{'-style'})
1732 1 5 unless ($options{'style'} =~ /^(?:[Rr]oman|[Aa]lpha|decimal)$/)
1766 8 0 if (exists $options{'style'})
1767 0 8 unless ($options{'style'} and $options{'style'} =~ /^([rad])/i)
1770 2 6 $1 eq 'd' ? :
1773 1 7 if (exists $options{'prefix'})
1777 1 7 if (exists $options{'start'})
1806 1 0 if (@_)
1837 6 11 unless (scalar @_)
1838 1 5 unless ($self->{'pages'}{$type})
1839 1 0 if $type eq "MediaBox"
1842 0 0 if $type eq "CropBox"
1860 2 3 unless @_
1867 0 1 unless @_
1874 0 1 unless @_
1881 0 1 unless @_
1888 0 1 unless @_
1966 0 1 if (exists $options{'kerning'})
1971 1 0 if ("PDF::API2::Resource::Font::CoreFont"->is_standard($name))
1976 0 0 $name =~ /\.bdf$/i ? :
0 0 $name =~ /\.pf[ab]$/i ? :
0 0 $name =~ /\.[ot]tf$/i ? :
1980 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 =~ /(\..*)$/) { }
1985 0 0 if (exists $options{'afm_file'})
1988 0 0 if (exists $options{'pfm_file'})
2026 0 0 unless exists $opts{'-unicodemap'}
2032 0 0 if $opts{'-unicodemap'}
2066 0 0 if ref $_[0]
2067 0 0 if $_[0] eq "PDF::API2"
2087 0 38 if ref $_[0]
2088 38 0 if $_[0] eq "PDF::API2"
2099 0 0 if -f $font
2103 0 0 if -f "$directory/$font"
2114 0 53 if $opts{'-unicodemap'}
2122 0 0 unless defined $opts{$o}
2125 0 0 unless $psf = _find_font($psf)
2130 0 0 if $opts{'-unicodemap'}
2142 0 0 unless exists $opts{'-unicodemap'}
2145 0 0 if ($opts{'-noembed'})
2150 0 0 unless my $file = _find_font($name)
2155 0 0 if $opts{'-unicodemap'}
2181 0 1 if $opts{'-unicodemap'}
2239 0 3 if (ref $file eq 'GD::Image') { }
3 0 elsif (ref $file) { }
2245 0 3 unless (ref $file)
2246 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 ? :
2253 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 =~ /(\..*)$/) { }
2290 0 3 unless $bytes_read and $bytes_read == 8
2292 1 2 if $test =~ /^GIF\d\d[a-z]/
2293 1 1 if $test =~ /^\xFF\xD8\xFF/
2294 1 0 if $test =~ /^\x89PNG\x0D\x0A\x1A\x0A/
2456 0 0 unless defined $format
2457 0 0 unless defined $value
2460 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') { }
2464 0 0 if ($options{'bar_extend'})
2476 0 0 if ($options{'bar_extend'})
2489 0 0 if ($options{'bar_extend'})
2497 0 0 unless ($options{'caption'})
2500 0 0 if ($options{'bar_extend'})
2508 0 0 if (exists $options{'caption'})
2511 0 0 if ($options{'bar_extend'} or $options{'font_size'})
2525 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') { }
2700 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') { }
2795 2 6 if (defined $value)
2841 0 0 unless (defined $obj)