| 1 | package PDF::Make::Builder; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 53 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 53 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 53 | ▶ | use File::Basename qw(dirname); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 53 | ▶ | use File::Path qw(make_path); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 53 | ▶ | use Object::Proto; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 53 | ▶ | use PDF::Make::Document; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 53 | ▶ | use PDF::Make::Canvas; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 53 | ▶ | use PDF::Make::Import; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 53 | ▶ | use PDF::Make::Page qw(:fonts); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 53 | ▶ | use PDF::Make::Builder::Font; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 53 | ▶ | use PDF::Make::Builder::Page; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 53 | ▶ | use PDF::Make::Builder::Page::Header; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 53 | ▶ | use PDF::Make::Builder::Page::Footer; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 53 | ▶ | use PDF::Make::Builder::Text; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 53 | ▶ | use PDF::Make::Builder::Text::H1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 53 | ▶ | use PDF::Make::Builder::Text::H2; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 53 | ▶ | use PDF::Make::Builder::Text::H3; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 53 | ▶ | use PDF::Make::Builder::Text::H4; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 53 | ▶ | use PDF::Make::Builder::Text::H5; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 53 | ▶ | use PDF::Make::Builder::Text::H6; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 53 | ▶ | use PDF::Make::Builder::Shape::Line; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 53 | ▶ | use PDF::Make::Builder::Shape::Box; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 53 | ▶ | use PDF::Make::Builder::Shape::Circle; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 53 | ▶ | use PDF::Make::Builder::Shape::Ellipse; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 53 | ▶ | use PDF::Make::Builder::Shape::Pie; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 53 | ▶ | use PDF::Make::Builder::TOC; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 53 | ▶ | use PDF::Make::Builder::Image; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 53 | ▶ | use PDF::Make::Builder::Layout; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 53 | ▶ | use PDF::Make::Builder::Form::Field; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 53 | ▶ | use PDF::Make::Builder::Form::Field::Text; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 53 | ▶ | use PDF::Make::Builder::Form::Field::Checkbox; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 53 | ▶ | use PDF::Make::Builder::Form::Field::Radio; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 53 | ▶ | use PDF::Make::Builder::Form::Field::Combo; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 53 | ▶ | use PDF::Make::Builder::Form::Field::Listbox; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 53 | ▶ | use PDF::Make::Builder::Form::Field::Button; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 53 | ▶ | use PDF::Make::Attachment; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 53 | ▶ | use PDF::Make::Color; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 53 | ▶ | use PDF::Make::Extract; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 53 | ▶ | use PDF::Make::Extract::Result; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 53 | ▶ | use PDF::Make::Font; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 53 | ▶ | use PDF::Make::Layer; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 53 | ▶ | use PDF::Make::Parser; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 53 | ▶ | use PDF::Make::Reader; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 53 | ▶ | use PDF::Make::Redaction; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 53 | ▶ | use PDF::Make::Signature; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 53 | ▶ | use PDF::Make::Structure; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 53 | ▶ | use PDF::Make::Watermark; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 53 | our $VERSION = '0.15'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 53 | ▶ | BEGIN { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 53 | Object::Proto::define('PDF::Make::Builder', | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 'file_name:Str:required', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 'doc:Any', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 'pages:ArrayRef:default([])', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 'page:Any', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 'page_args:HashRef:default({})', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 'page_offset:Int:default(0)', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 'onsave_cbs:ArrayRef:default([])', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 'configure:HashRef:default({})', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 'font:Any', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 'toc:Any', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | '_header_args:HashRef', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | '_footer_args:HashRef', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | '_outlines:HashRef:default({})', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | '_layers:HashRef:default({})', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | '_encrypt_args:HashRef', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | '_sign_args:HashRef', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | '_watermarks:ArrayRef:default([])', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | '_tagging:Any', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | '_struct_tree:Any', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | '_struct_stack:ArrayRef:default([])', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | '_flatten_pending:Bool:default(0)', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | '_apply_redactions_pending:Bool:default(0)', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | '_sanitize_pending:Bool:default(0)', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | '_finalised:Bool:default(0)', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | '_signed_cache:Any', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | '_ttf_fonts:HashRef:default({})', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 53 | Object::Proto::import_accessors('PDF::Make::Builder'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 616 | ▶ | sub BUILD { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BUILD: called CC=8 SCAR=20.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 616 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 616 | doc $self, PDF::Make::Document->new; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | # Default font | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 616 | my $cfg = configure $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 616 | ▶ | my $font_args = $cfg->{text}{font} // {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$cfg->{"text"}{"font"} // {}
MC/DC100%1/1
$cfg->{"text"}{"font"} // {}
$cfg->{"text"}{"font"}
Truth table100%2/2
A
A= $cfg->{"text"}{"font"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | my %font_init = ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | colour => $font_args->{colour} // '#000', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | size => $font_args->{size} // 9, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 616 | ▶ | family => $font_args->{family} // 'Helvetica', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%6/6
$font_args->{"colour"} // "#000"
$font_args->{"size"} // 9
$font_args->{"family"} // "Helvetica"
MC/DC100%1/1
$font_args->{"colour"} // "#000"
$font_args->{"colour"}
MC/DC100%1/1
$font_args->{"size"} // 9
$font_args->{"size"}
MC/DC100%1/1
$font_args->{"family"} // "Helvetica"
$font_args->{"family"}
Truth table100%2/2
A
A= $font_args->{"colour"}
Truth table100%2/2
A
A= $font_args->{"size"}
Truth table100%2/2
A
A= $font_args->{"family"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 616 | ▶ | $font_init{line_height} = $font_args->{line_height} if defined $font_args->{line_height}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 616 | $font_init{registry} = _ttf_fonts $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 616 | font $self, PDF::Make::Builder::Font->new(%font_init); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | # Store header/footer config for new pages | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 616 | ▶ | if ($cfg->{page_header}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 1 | _header_args $self, $cfg->{page_header}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 616 | ▶ | if ($cfg->{page_footer}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 1 | _footer_args $self, $cfg->{page_footer}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | # ── Page management ──────────────────────────────────────── | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 574 | ▶ | sub add_page { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_page: called CC=10 SCAR=23.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 574 | my ($self, %args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 574 | ▶ | my $page_size = $args{page_size} // 'A4'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$args{"page_size"} // "A4"
MC/DC100%1/1
$args{"page_size"} // "A4"
$args{"page_size"}
Truth table100%2/2
A
A= $args{"page_size"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 574 | my ($pw, $ph) = PDF::Make::Builder::Page::page_dimensions($page_size); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 574 | ▶ | my $padding = $args{padding} // 20; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$args{"padding"} // 20
MC/DC100%1/1
$args{"padding"} // 20
$args{"padding"}
Truth table100%2/2
A
A= $args{"padding"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 574 | my $xs_doc = doc $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 574 | my $xs_page = $xs_doc->add_page($pw, $ph); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 574 | my $canvas = PDF::Make::Canvas->new; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 574 | my $pages = pages $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 574 | my $num = scalar(@$pages) + 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | # Build header/footer from stored config | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 574 | my $hdr_args = _header_args $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 574 | my $ftr_args = _footer_args $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 574 | ▶ | my $header = $hdr_args ? PDF::Make::Builder::Page::Header->new(%$hdr_args) : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 574 | ▶ | my $footer = $ftr_args ? PDF::Make::Builder::Page::Footer->new(%$ftr_args) : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | my $bp = PDF::Make::Builder::Page->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | page_size => $page_size, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | background => $args{background} // '#fff', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 574 | ▶ | columns => $args{columns} // 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%4/4
$args{"background"} // "#fff"
$args{"columns"} // 1
MC/DC100%1/1
$args{"background"} // "#fff"
$args{"background"}
MC/DC100%1/1
$args{"columns"} // 1
$args{"columns"}
Truth table100%2/2
A
A= $args{"background"}
Truth table100%2/2
A
A= $args{"columns"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | padding => $padding, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | num => $num, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | w => $pw, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | h => $ph, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | canvas => $canvas, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | xs_page => $xs_page, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | header => $header, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | footer => $footer, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | # Draw background if not white | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 574 | my $bg = $bp->background; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 574 | ▶ | if ($bg && $bg ne '#fff' && $bg ne '#ffffff') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
$bg and $bg ne "#fff" and $bg ne "#ffffff"
$bg and $bg ne "#fff"
MC/DC33%1/3
$bg and $bg ne "#fff" and $bg ne "#ffffff"
$bg
$bg ne "#fff"
$bg ne "#ffffff"
Truth table50%2/4
A and B and C
A= $bgB= $bg ne "#fff"C= $bg ne "#ffffff"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 2 | my ($r, $g, $b) = (font $self)->hex_to_rgb($bg); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 2 | $canvas->q->rg($r, $g, $b)->re(0, 0, $pw, $ph)->f->Q; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 574 | push @$pages, $bp; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 574 | pages $self, $pages; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 574 | page $self, $bp; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 574 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 4 | ▶ | sub open_page { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
open_page: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 4 | my ($self, $num) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 4 | my $pages = pages $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 4 | ▶ | die "PDF::Make::Builder: page $num does not exist" unless $num >= 1 && $num <= scalar @$pages; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$num >= 1 and $num <= scalar @$pages
MC/DC50%1/2
$num >= 1 and $num <= scalar @$pages
$num >= 1
$num <= scalar @$pages
Truth table66%2/3
A and B
A= $num >= 1B= $num <= scalar @$pages
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 3 | page $self, $pages->[$num - 1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 3 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 4 | ▶ | sub set_columns { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_columns: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 4 | my ($self, $n) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 4 | my $p = page $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 4 | ▶ | die "PDF::Make::Builder: no current page" unless $p; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 3 | $p->columns($n); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 3 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 2 | ▶ | sub page_width { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
page_width: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 2 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 2 | my $p = page $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 2 | ▶ | return $p ? $p->w : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 2 | ▶ | sub page_height { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
page_height: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 2 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 2 | my $p = page $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 2 | ▶ | return $p ? $p->h : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 2 | ▶ | sub current_x { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
current_x: called CC=3 SCAR=11.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 2 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 2 | my $p = page $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 2 | ▶ | return $p ? ($p->x || $p->content_x) : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$p->x or $p->content_x
MC/DC0%0/2
$p->x or $p->content_x
$p->x
$p->content_x
Truth table33%1/3
A or B
A= $p->xB= $p->content_x
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 7 | ▶ | sub current_y { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
current_y: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 7 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 7 | my $p = page $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 7 | ▶ | return $p ? $p->cursor_y : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 2 | ▶ | sub content_left { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
content_left: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 2 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 2 | my $p = page $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 2 | ▶ | return $p ? $p->content_x : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 2 | ▶ | sub content_right { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
content_right: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 2 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 2 | my $p = page $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 2 | ▶ | return $p ? ($p->content_x + $p->width) : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 2 | ▶ | sub content_bottom { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
content_bottom: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 2 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 2 | my $p = page $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 2 | ▶ | return $p ? $p->bottom_y : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 2 | ▶ | sub content_top { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
content_top: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 2 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 2 | my $p = page $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 2 | ▶ | return $p ? $p->top_y : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 4 | ▶ | sub cursor_move_to { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
cursor_move_to: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 4 | my ($self, $x, $y) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 4 | my $p = page $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 4 | ▶ | die "PDF::Make::Builder: no current page" unless $p; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 3 | ▶ | $p->x($x) if defined $x; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 3 | ▶ | $p->y($y) if defined $y; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 3 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 3 | ▶ | sub cursor_advance_y { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
cursor_advance_y: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 3 | my ($self, $dy) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 3 | my $p = page $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 3 | ▶ | die "PDF::Make::Builder: no current page" unless $p; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 2 | ▶ | $dy //= 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$dy //= 0
MC/DC100%1/1
$dy //= 0
$dy
Truth table100%2/2
A
A= $dy
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 2 | $p->y($p->cursor_y + $dy); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 2 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | # ── Layout ──────────────────────────────────────────────── | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 382 | ▶ | sub layout { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
layout: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 382 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 382 | return PDF::Make::Builder::Layout->new(builder => $self); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | # ── Header/Footer ───────────────────────────────────────── | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 17 | ▶ | sub add_page_header { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_page_header: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 17 | my ($self, %args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 17 | _header_args $self, \%args; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 17 | my $p = page $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 17 | ▶ | if ($p) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 4 | $p->header(PDF::Make::Builder::Page::Header->new(%args)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 17 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 9 | ▶ | sub add_page_footer { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_page_footer: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 9 | my ($self, %args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 9 | _footer_args $self, \%args; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 9 | my $p = page $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 9 | ▶ | if ($p) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 3 | $p->footer(PDF::Make::Builder::Page::Footer->new(%args)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 9 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 2 | ▶ | sub remove_page_header { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
remove_page_header: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 2 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 2 | _header_args $self, undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 2 | my $p = page $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 2 | ▶ | $p->header(undef) if $p; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | 2 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 2 | ▶ | sub remove_page_footer { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
remove_page_footer: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 2 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 2 | _footer_args $self, undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 2 | my $p = page $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 2 | ▶ | $p->footer(undef) if $p; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 2 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 1 | ▶ | sub remove_page_header_and_footer { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
remove_page_header_and_footer: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 1 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 1 | $self->remove_page_header; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 1 | $self->remove_page_footer; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 1 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | # ── Font ─────────────────────────────────────────────────── | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 1 | ▶ | sub load_font { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
load_font: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 1 | my ($self, %args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 1 | ▶ | $args{registry} = _ttf_fonts $self unless exists $args{registry}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 1 | font $self, PDF::Make::Builder::Font->new(%args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | 1 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | # ── Text content ─────────────────────────────────────────── | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | 436 | ▶ | sub _apply_configure { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_apply_configure: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 436 | my ($self, $type, $args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 436 | my $cfg = configure $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 436 | ▶ | my $defaults = $cfg->{$type} // {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$cfg->{$type} // {}
MC/DC100%1/1
$cfg->{$type} // {}
$cfg->{$type}
Truth table100%2/2
A
A= $cfg->{$type}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 436 | ▶ | if ($defaults->{font}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 6 | ▶ | $args->{font} = { %{$defaults->{font}}, %{$args->{font} // {}} }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$args->{"font"} // {}
MC/DC100%1/1
$args->{"font"} // {}
$args->{"font"}
Truth table100%2/2
A
A= $args->{"font"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 436 | return $args; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 446 | ▶ | sub _tag_begin { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_tag_begin: called CC=4 SCAR=14.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | 446 | my ($self, $tag_type) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | 446 | ▶ | return unless _tagging $self; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | 2 | my $tree = _struct_tree $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | 2 | ▶ | return unless $tree; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | 2 | my $stack = _struct_stack $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 2 | ▶ | my $parent = @$stack ? $stack->[-1] : $tree->root; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | 2 | my $elem = $parent->add_child($tag_type); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | 2 | push @$stack, $elem; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 2 | _struct_stack $self, $stack; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 446 | ▶ | sub _tag_end { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_tag_end: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | 446 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | 446 | ▶ | return unless _tagging $self; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | 2 | my $stack = _struct_stack $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | 2 | ▶ | pop @$stack if @$stack; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | 2 | _struct_stack $self, $stack; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | 375 | ▶ | sub add_text { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_text: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | 375 | my ($self, %args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | 375 | $self->_apply_configure('text', \%args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | # Styled runs still need the plain string: text is a required property, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | # and it is what tagged output and extraction read. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 375 | ▶ | if (!defined $args{text} && ref $args{runs} eq 'ARRAY') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not defined $args{"text"} and ref $args{"runs"} eq "ARRAY"
MC/DC50%1/2
not defined $args{"text"} and ref $args{"runs"} eq "ARRAY"
not defined $args{"text"}
ref $args{"runs"} eq "ARRAY"
Truth table66%2/3
not(A) and B
A= not defined $args{"text"}B= ref $args{"runs"} eq "ARRAY"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | $args{text} = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 6 | PDF::Make::Builder::Text::plain_text_from_runs($args{runs}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | 375 | $self->_tag_begin('P'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | 375 | my $t = PDF::Make::Builder::Text->new(%args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | 375 | $t->add($self); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | 375 | $self->_tag_end; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 375 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | 41 | ▶ | sub add_h1 { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_h1: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | 41 | my ($self, %args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | 41 | $self->_apply_configure('h1', \%args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | 41 | $self->_tag_begin('H1'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 41 | my $t = PDF::Make::Builder::Text::H1->new(%args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | 41 | $t->add($self); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 41 | $self->_tag_end; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | 41 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | 7 | ▶ | sub add_h2 { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_h2: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | 7 | my ($self, %args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | 7 | $self->_apply_configure('h2', \%args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | 7 | $self->_tag_begin('H2'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | 7 | my $t = PDF::Make::Builder::Text::H2->new(%args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | 7 | $t->add($self); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | 7 | $self->_tag_end; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | 7 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | 4 | ▶ | sub add_h3 { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_h3: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | 4 | my ($self, %args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | 4 | $self->_apply_configure('h3', \%args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 4 | $self->_tag_begin('H3'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | 4 | my $t = PDF::Make::Builder::Text::H3->new(%args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | 4 | $t->add($self); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | 4 | $self->_tag_end; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | 4 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | 3 | ▶ | sub add_h4 { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_h4: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | 3 | my ($self, %args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | 3 | $self->_apply_configure('h4', \%args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | 3 | $self->_tag_begin('H4'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | 3 | my $t = PDF::Make::Builder::Text::H4->new(%args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | 3 | $t->add($self); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | 3 | $self->_tag_end; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | 3 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | 3 | ▶ | sub add_h5 { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_h5: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | 3 | my ($self, %args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | 3 | $self->_apply_configure('h5', \%args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | 3 | $self->_tag_begin('H5'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | 3 | my $t = PDF::Make::Builder::Text::H5->new(%args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | 3 | $t->add($self); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | 3 | $self->_tag_end; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | 3 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | 3 | ▶ | sub add_h6 { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_h6: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | 3 | my ($self, %args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | 3 | $self->_apply_configure('h6', \%args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | 3 | $self->_tag_begin('H6'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | 3 | my $t = PDF::Make::Builder::Text::H6->new(%args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | 3 | $t->add($self); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | 3 | $self->_tag_end; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | 3 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | 1 | ▶ | sub add_lines { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_lines: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | 1 | my ($self, @lines) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | 1 | for my $line (@lines) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | 3 | ▶ | if (ref $line eq 'HASH') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | 1 | $self->add_text(%$line); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | 2 | $self->add_text(text => $line); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | 1 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | # ── Shapes ───────────────────────────────────────────────── | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | 8 | ▶ | sub add_line { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_line: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | 8 | my ($self, %args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | 8 | my $s = PDF::Make::Builder::Shape::Line->new(%args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | 8 | $s->add($self); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | 8 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | 15 | ▶ | sub add_box { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_box: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | 15 | my ($self, %args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | 15 | my $s = PDF::Make::Builder::Shape::Box->new(%args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | 15 | $s->add($self); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | 15 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | 1 | ▶ | sub add_circle { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_circle: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | 1 | my ($self, %args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | 1 | my $s = PDF::Make::Builder::Shape::Circle->new(%args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | 1 | $s->add($self); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | 1 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | 1 | ▶ | sub add_ellipse { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_ellipse: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | 1 | my ($self, %args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | 1 | my $s = PDF::Make::Builder::Shape::Ellipse->new(%args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | 1 | $s->add($self); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | 1 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | 1 | ▶ | sub add_pie { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_pie: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | 1 | my ($self, %args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | 1 | my $s = PDF::Make::Builder::Shape::Pie->new(%args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | 1 | $s->add($self); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | 1 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | # ── Images ───────────────────────────────────────────────── | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | 10 | ▶ | sub add_image { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_image: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | 10 | my ($self, %args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | 10 | $self->_tag_begin('Figure'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | 10 | my $img = PDF::Make::Builder::Image->new(%args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | 10 | $img->add($self); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | 10 | $self->_tag_end; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | 10 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | # ── Metadata ─────────────────────────────────────────────── | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | 3 | ▶ | sub title { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
title: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | 3 | my ($self, $val) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | 3 | (doc $self)->title($val); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | 3 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | 3 | ▶ | sub author { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
author: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | 3 | my ($self, $val) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | 3 | (doc $self)->author($val); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | 3 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | 1 | ▶ | sub subject { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
subject: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | 1 | my ($self, $val) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | 1 | (doc $self)->subject($val); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | 1 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | 1 | ▶ | sub keywords { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
keywords: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | 1 | my ($self, $val) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | 1 | (doc $self)->keywords($val); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | 1 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | 1 | ▶ | sub creator { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
creator: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | 1 | my ($self, $val) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | 1 | (doc $self)->creator($val); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | 1 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | 1 | ▶ | sub producer { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
producer: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | 1 | my ($self, $val) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | 1 | (doc $self)->producer($val); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | 1 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | # ── Outlines/Bookmarks ──────────────────────────────────── | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | 11 | ▶ | sub add_outline { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_outline: called CC=8 SCAR=20.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | 11 | my ($self, $title, %args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | 11 | ▶ | my $page_index = $args{page} // 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$args{"page"} // 0
MC/DC0%0/1
$args{"page"} // 0
$args{"page"}
Truth table50%1/2
A
A= $args{"page"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | 11 | ▶ | my $dest_type = $args{dest} // 'Fit'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$args{"dest"} // "Fit"
MC/DC100%1/1
$args{"dest"} // "Fit"
$args{"dest"}
Truth table100%2/2
A
A= $args{"dest"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | 11 | my $parent_key = $args{parent}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | 11 | ▶ | my $left = $args{left} // 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$args{"left"} // 0
MC/DC100%1/1
$args{"left"} // 0
$args{"left"}
Truth table100%2/2
A
A= $args{"left"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | 11 | ▶ | my $top = $args{top} // 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$args{"top"} // 0
MC/DC100%1/1
$args{"top"} // 0
$args{"top"}
Truth table100%2/2
A
A= $args{"top"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | 11 | ▶ | my $zoom = $args{zoom} // 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$args{"zoom"} // 0
MC/DC100%1/1
$args{"zoom"} // 0
$args{"zoom"}
Truth table100%2/2
A
A= $args{"zoom"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | 11 | my $outlines = _outlines $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | 11 | my $item; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | 11 | ▶ | if ($parent_key && $outlines->{$parent_key}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$parent_key and $outlines->{$parent_key}
MC/DC100%2/2
$parent_key and $outlines->{$parent_key}
$parent_key
$outlines->{$parent_key}
Truth table100%3/3
A and B
A= $parent_keyB= $outlines->{$parent_key}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | 3 | $item = $outlines->{$parent_key}->add_child( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | $title, $page_index, $dest_type, $left, $top, $zoom | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | 8 | $item = (doc $self)->add_outline( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | $title, $page_index, $dest_type, $left, $top, $zoom | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | 11 | $outlines->{$title} = $item; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | 11 | _outlines $self, $outlines; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | 11 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | # ── Links/Actions ───────────────────────────────────────── | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | 20 | ▶ | sub add_link { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_link: called CC=25 SCAR=34.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | 20 | my ($self, %args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | 20 | my $xs_doc = doc $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | 20 | my $target_builder_page; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | 20 | ▶ | if (defined $args{on_page}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | 10 | my $idx = $args{on_page}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | 10 | my $all = pages $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | 10 | ▶ | die "PDF::Make::Builder: on_page $idx does not exist" unless $all && $idx >= 0 && $idx < @$all; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%3/6
$all and $idx >= 0 and $idx < @$all
$all and $idx >= 0
MC/DC33%1/3
$all and $idx >= 0 and $idx < @$all
$all
$idx >= 0
$idx < @$all
Truth table50%2/4
A and B and C
A= $allB= $idx >= 0C= $idx < @$all
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | 9 | $target_builder_page = $all->[$idx]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | 10 | $target_builder_page = page $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | 10 | ▶ | die "PDF::Make::Builder: add_link requires a current page" unless $target_builder_page; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | 19 | my $rect; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | 19 | ▶ | if ($args{rect}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | 16 | $rect = $args{rect}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | ▶ | } elsif (defined $args{x} || defined $args{y} || defined $args{w} || defined $args{h}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%3/9
defined $args{"x"} or defined $args{"y"} or defined $args{"w"} or defined $args{"h"}
defined $args{"x"} or defined $args{"y"} or defined $args{"w"}
defined $args{"x"} or defined $args{"y"}
MC/DC0%0/4
defined $args{"x"} or defined $args{"y"} or defined $args{"w"} or defined $args{"h"}
defined $args{"x"}
defined $args{"y"}
defined $args{"w"}
defined $args{"h"}
Truth table20%1/5
A or B or C or D
A= defined $args{"x"}B= defined $args{"y"}C= defined $args{"w"}D= defined $args{"h"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | die "PDF::Make::Builder: add_link builder coords require x,y,w,h" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | 3 | ▶ | unless defined $args{x} && defined $args{y} && defined $args{w} && defined $args{h}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition55%5/9
defined $args{"x"} and defined $args{"y"} and defined $args{"w"} and defined $args{"h"}
defined $args{"x"} and defined $args{"y"} and defined $args{"w"}
defined $args{"x"} and defined $args{"y"}
MC/DC25%1/4
defined $args{"x"} and defined $args{"y"} and defined $args{"w"} and defined $args{"h"}
defined $args{"x"}
defined $args{"y"}
defined $args{"w"}
defined $args{"h"}
Truth table40%2/5
A and B and C and D
A= defined $args{"x"}B= defined $args{"y"}C= defined $args{"w"}D= defined $args{"h"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | 2 | my ($x, $y, $w, $h) = @args{qw/x y w h/}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | 2 | my $x0 = $x; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | 2 | my $x1 = $x + $w; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | 2 | my $y0 = $y; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | 2 | my $y1 = $y + $h; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | 2 | $rect = [$x0, $y0, $x1, $y1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | 0 | die "PDF::Make::Builder: add_link requires rect => [x0,y0,x1,y1] or builder coords x,y,w,h"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | 18 | ▶ | my $hl = $args{highlight} // 'Invert'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$args{"highlight"} // "Invert"
MC/DC0%0/1
$args{"highlight"} // "Invert"
$args{"highlight"}
Truth table50%1/2
A
A= $args{"highlight"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | 18 | my $annot_num; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | 18 | ▶ | if ($args{url}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | 3 | $annot_num = $xs_doc->add_link_uri(@$rect, $args{url}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | } elsif (defined $args{page}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | 12 | $annot_num = $xs_doc->add_link_goto(@$rect, $args{page}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | } elsif ($args{action}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | # Named action: NextPage, PrevPage, FirstPage, LastPage, Print | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | 1 | $annot_num = $xs_doc->add_link_named_action(@$rect, $args{action}, $hl); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | } elsif ($args{file}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | # External PDF link (GoToR) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | 1 | ▶ | my $action = $xs_doc->action_gotor($args{file}, $args{file_page} // 0, $args{new_window} // 0); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%2/4
$args{"file_page"} // 0
$args{"new_window"} // 0
MC/DC0%0/1
$args{"file_page"} // 0
$args{"file_page"}
MC/DC0%0/1
$args{"new_window"} // 0
$args{"new_window"}
Truth table50%1/2
A
A= $args{"file_page"}
Truth table50%1/2
A
A= $args{"new_window"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | 1 | $annot_num = $xs_doc->add_link_with_action(@$rect, $action, $hl); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | 1 | die "PDF::Make::Builder: add_link requires url, page, action, or file"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | 17 | ▶ | if ($annot_num) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | 17 | my $page_obj; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | 17 | ▶ | if (defined $args{on_page}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | 9 | my $target_page = $args{on_page}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | 9 | $page_obj = $xs_doc->get_page($target_page); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | 9 | ▶ | die "PDF::Make::Builder: on_page $target_page does not exist" unless $page_obj; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | 8 | $page_obj = $target_builder_page->xs_page; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | 17 | $page_obj->add_annot($annot_num); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | 17 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | # ── Annotations ────────────────────────────────────────── | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | 10 | ▶ | sub add_note { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_note: called CC=30 SCAR=34.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | 10 | my ($self, %args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | # Visual note mode: draw a coloured callout box with lines of text | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | 10 | ▶ | if (exists $args{lines} || (exists $args{text} && ref $args{text} eq 'ARRAY')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
exists $args{"lines"} or exists $args{"text"} and ref $args{"text"} eq "ARRAY"
exists $args{"text"} and ref $args{"text"} eq "ARRAY"
MC/DC100%3/3
exists $args{"lines"} or exists $args{"text"} and ref $args{"text"} eq "ARRAY"
exists $args{"lines"}
exists $args{"text"}
ref $args{"text"} eq "ARRAY"
Truth table100%4/4
A or B and C
A= exists $args{"lines"}B= exists $args{"text"}C= ref $args{"text"} eq "ARRAY"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | 4 | ▶ | my $lines = $args{lines} // $args{text}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$args{"lines"} // $args{"text"}
MC/DC0%0/2
$args{"lines"} // $args{"text"}
$args{"lines"}
$args{"text"}
Truth table66%2/3
A // B
A= $args{"lines"}B= $args{"text"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | 4 | ▶ | my $x = $args{x} // 72; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$args{"x"} // 72
MC/DC100%1/1
$args{"x"} // 72
$args{"x"}
Truth table100%2/2
A
A= $args{"x"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | 4 | ▶ | my $w = $args{w} // 300; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$args{"w"} // 300
MC/DC100%1/1
$args{"w"} // 300
$args{"w"}
Truth table100%2/2
A
A= $args{"w"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | 4 | ▶ | my $h = $args{h} // 70; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$args{"h"} // 70
MC/DC100%1/1
$args{"h"} // 70
$args{"h"}
Truth table100%2/2
A
A= $args{"h"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | 4 | ▶ | my $bg = $args{bg_colour} // $args{fill_colour} // '#fffbeb'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition40%2/5
($args{"bg_colour"} // $args{"fill_colour"}) // "#fffbeb"
$args{"bg_colour"} // $args{"fill_colour"}
MC/DC0%0/2
($args{"bg_colour"} // $args{"fill_colour"}) // "#fffbeb"
$args{"bg_colour"}
$args{"fill_colour"}
Truth table33%1/3
A // B
A= $args{"bg_colour"}B= $args{"fill_colour"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | 4 | ▶ | my $padding = $args{padding} // 12; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$args{"padding"} // 12
MC/DC100%1/1
$args{"padding"} // 12
$args{"padding"}
Truth table100%2/2
A
A= $args{"padding"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | 4 | ▶ | my $line_gap = $args{line_gap} // 14; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$args{"line_gap"} // 14
MC/DC0%0/1
$args{"line_gap"} // 14
$args{"line_gap"}
Truth table50%1/2
A
A= $args{"line_gap"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | 4 | ▶ | my $colour = $args{colour} // '#92400e'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$args{"colour"} // "#92400e"
MC/DC0%0/1
$args{"colour"} // "#92400e"
$args{"colour"}
Truth table50%1/2
A
A= $args{"colour"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | 4 | ▶ | my $size = $args{size} // 10; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$args{"size"} // 10
MC/DC0%0/1
$args{"size"} // 10
$args{"size"}
Truth table50%1/2
A
A= $args{"size"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | 4 | my $cur = page $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | 4 | ▶ | die "PDF::Make::Builder: add_note requires a current page" unless $cur; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | 3 | my $y; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | 3 | ▶ | if (defined $args{y}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | 1 | $y = $args{y}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | 2 | $y = $cur->cursor_y - $h; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | 2 | $cur->advance_y($h + 6); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | 3 | $self->add_box(fill_colour => $bg, x => $x, y => $y, w => $w, h => $h); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | 3 | my $ty = $y + $h - $padding - $size; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | 3 | for my $line (@$lines) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | my ($text, $fsize, $fcol, $italic) = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | ref $line eq 'HASH' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | 7 | ▶ | ? (@{$line}{qw(text size colour italic)}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | : ($line, undef, undef, 0); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | 7 | ▶ | $fsize //= $size; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$fsize //= $size
MC/DC0%0/2
$fsize //= $size
$fsize
$size
Truth table66%2/3
A //= B
A= $fsizeB= $size
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | 7 | ▶ | $fcol //= $colour; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$fcol //= $colour
MC/DC0%0/2
$fcol //= $colour
$fcol
$colour
Truth table66%2/3
A //= B
A= $fcolB= $colour
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | 7 | ▶ | $self->add_text( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 641 | text => $text, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 642 | x => $x + $padding, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 643 | y => $ty, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 644 | w => $w - $padding * 2, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 645 | font => { size => $fsize, colour => $fcol, ($italic ? (italic => 1) : ()) }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 646 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 647 | 7 | $ty -= $line_gap; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 648 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 649 | 3 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 650 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 651 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 652 | # Annotation note mode (PDF sticky note) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 653 | 6 | my $xs_doc = doc $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 654 | 6 | ▶ | my $rect = $args{rect} // die "PDF::Make::Builder: add_note requires rect or lines"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$args{"rect"} // die("PDF::Make::Builder: add_note requires rect or lines")
MC/DC100%1/1
$args{"rect"} // die("PDF::Make::Builder: add_note requires rect or lines")
$args{"rect"}
Truth table100%2/2
A
A= $args{"rect"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 655 | 5 | ▶ | my $text = $args{text} // ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$args{"text"} // ""
MC/DC100%1/1
$args{"text"} // ""
$args{"text"}
Truth table100%2/2
A
A= $args{"text"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 656 | 5 | ▶ | my $icon = $args{icon} // 'Note'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$args{"icon"} // "Note"
MC/DC100%1/1
$args{"icon"} // "Note"
$args{"icon"}
Truth table100%2/2
A
A= $args{"icon"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 657 | 5 | ▶ | my $open = $args{open} // 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$args{"open"} // 0
MC/DC100%1/1
$args{"open"} // 0
$args{"open"}
Truth table100%2/2
A
A= $args{"open"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 658 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 659 | # Resolve target page (defaults to current) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 660 | 5 | my $target = $args{page}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 661 | 5 | my $xs_page; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 662 | 5 | ▶ | if (defined $target) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 663 | 2 | my $ps = pages $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 664 | 2 | ▶ | die "PDF::Make::Builder: add_note: page index out of range" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$target >= 0 and $target < scalar @$ps
MC/DC50%1/2
$target >= 0 and $target < scalar @$ps
$target >= 0
$target < scalar @$ps
Truth table66%2/3
A and B
A= $target >= 0B= $target < scalar @$ps
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 665 | unless $target >= 0 && $target < scalar @$ps; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 666 | 1 | $xs_page = $ps->[$target]->xs_page; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 667 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 668 | 3 | ▶ | my $cur = page $self or die "PDF::Make::Builder: add_note requires a current page"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 669 | 3 | $xs_page = $cur->xs_page; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 670 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 671 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 672 | 4 | my $annot_num = $xs_doc->add_text_annot(@$rect, $text, $icon, $open); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 673 | 4 | ▶ | $xs_page->add_annot($annot_num) if $annot_num; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 674 | 4 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 675 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 676 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 677 | 7 | ▶ | sub add_stamp { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_stamp: called CC=16 SCAR=29.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 678 | 7 | my ($self, %args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 679 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 680 | # Visual stamp mode: draw a coloured box with centred bold label | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 681 | 7 | ▶ | if (exists $args{text}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 682 | 3 | my $text = $args{text}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 683 | 3 | ▶ | my $x = $args{x} // 72; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$args{"x"} // 72
MC/DC0%0/1
$args{"x"} // 72
$args{"x"}
Truth table50%1/2
A
A= $args{"x"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 684 | 3 | ▶ | my $w = $args{w} // 200; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$args{"w"} // 200
MC/DC0%0/1
$args{"w"} // 200
$args{"w"}
Truth table50%1/2
A
A= $args{"w"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 685 | 3 | ▶ | my $h = $args{h} // 50; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$args{"h"} // 50
MC/DC0%0/1
$args{"h"} // 50
$args{"h"}
Truth table50%1/2
A
A= $args{"h"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 686 | 3 | ▶ | my $bg = $args{bg_colour} // $args{fill_colour} // '#e5e7eb'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition40%2/5
($args{"bg_colour"} // $args{"fill_colour"}) // "#e5e7eb"
$args{"bg_colour"} // $args{"fill_colour"}
MC/DC0%0/2
($args{"bg_colour"} // $args{"fill_colour"}) // "#e5e7eb"
$args{"bg_colour"}
$args{"fill_colour"}
Truth table33%1/3
A // B
A= $args{"bg_colour"}B= $args{"fill_colour"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 687 | 3 | ▶ | my $colour = $args{colour} // '#111827'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$args{"colour"} // "#111827"
MC/DC0%0/1
$args{"colour"} // "#111827"
$args{"colour"}
Truth table50%1/2
A
A= $args{"colour"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 688 | 3 | ▶ | my $size = $args{size} // 20; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$args{"size"} // 20
MC/DC0%0/1
$args{"size"} // 20
$args{"size"}
Truth table50%1/2
A
A= $args{"size"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 689 | 3 | ▶ | my $border = $args{border} // 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$args{"border"} // 0
MC/DC0%0/1
$args{"border"} // 0
$args{"border"}
Truth table50%1/2
A
A= $args{"border"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 690 | 3 | ▶ | my $border_col = $args{border_colour} // $colour; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$args{"border_colour"} // $colour
MC/DC0%0/2
$args{"border_colour"} // $colour
$args{"border_colour"}
$colour
Truth table33%1/3
A // B
A= $args{"border_colour"}B= $colour
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 691 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 692 | 3 | my $cur = page $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 693 | 3 | ▶ | die "PDF::Make::Builder: add_stamp requires a current page" unless $cur; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 694 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 695 | 2 | my $y; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 696 | 2 | ▶ | if (defined $args{y}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 697 | 1 | $y = $args{y}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 698 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 699 | 1 | $y = $cur->cursor_y - $h; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 700 | 1 | $cur->advance_y($h + 6); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 701 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 702 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 703 | 2 | ▶ | $self->add_box( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 704 | fill_colour => $bg, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 705 | x => $x, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 706 | y => $y, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 707 | w => $w, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 708 | h => $h, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 709 | ($border ? (border_colour => $border_col, border_width => $border) : ()), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 710 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 711 | 2 | $self->add_text( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 712 | text => $text, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 713 | x => $x, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 714 | y => $y + ($h / 2) + ($size * 0.66), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 715 | w => $w, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 716 | align => 'center', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 717 | font => { size => $size, colour => $colour, bold => 1 }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 718 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 719 | 2 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 720 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 721 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 722 | # Annotation stamp mode | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 723 | 4 | my $xs_doc = doc $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 724 | 4 | ▶ | my $rect = $args{rect} // die "PDF::Make::Builder: add_stamp requires rect or text"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$args{"rect"} // die("PDF::Make::Builder: add_stamp requires rect or text")
MC/DC100%1/1
$args{"rect"} // die("PDF::Make::Builder: add_stamp requires rect or text")
$args{"rect"}
Truth table100%2/2
A
A= $args{"rect"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 725 | 3 | ▶ | my $type = $args{type} // 'Draft'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$args{"type"} // "Draft"
MC/DC0%0/1
$args{"type"} // "Draft"
$args{"type"}
Truth table50%1/2
A
A= $args{"type"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 726 | 3 | $xs_doc->add_stamp(@$rect, $type); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 727 | 3 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 728 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 729 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 730 | # ── Bates Numbering ────────────────────────────────────── | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 731 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 732 | 1 | ▶ | sub add_bates { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_bates: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 733 | 1 | my ($self, %args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 734 | 1 | my $stamp = PDF::Make::Stamp->bates(%args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 735 | 1 | my $xs_doc = doc $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 736 | 53 | ▶ | no warnings 'uninitialized'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 737 | 1 | $xs_doc->apply_stamp($stamp); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 738 | 1 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 739 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 740 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 741 | # ── Custom Metadata ────────────────────────────────────── | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 742 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 743 | 2 | ▶ | sub set_meta { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_meta: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 744 | 2 | my ($self, $key, $value) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 745 | 2 | (doc $self)->set_meta($key, $value); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 746 | 2 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 747 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 748 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 749 | 2 | ▶ | sub get_meta { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_meta: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 750 | 2 | my ($self, $key) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 751 | 2 | return (doc $self)->get_meta($key); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 752 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 753 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 754 | # ── Page Info ──────────────────────────────────────────── | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 755 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 756 | 26 | ▶ | sub page_count { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
page_count: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 757 | 26 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 758 | 26 | return scalar @{pages $self}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 759 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 760 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 761 | # ── Output ─────────────────────────────────────────────── | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 762 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 763 | # ── Attachments ─────────────────────────────────────────── | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 764 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 765 | 1 | ▶ | sub attach { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
attach: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 766 | 1 | my ($self, %args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 767 | 1 | my $xs_doc = doc $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 768 | 1 | PDF::Make::Attachment->attach($xs_doc, %args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 769 | 1 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 770 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 771 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 772 | # ── Watermarks ──────────────────────────────────────────── | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 773 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 774 | 1 | ▶ | sub add_watermark { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_watermark: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 775 | 1 | my ($self, %args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 776 | 1 | ▶ | my $text = delete $args{text} // die "PDF::Make::Builder: add_watermark requires text"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
delete $args{"text"} // die("PDF::Make::Builder: add_watermark requires text")
MC/DC0%0/1
delete $args{"text"} // die("PDF::Make::Builder: add_watermark requires text")
delete $args{"text"}
Truth table50%1/2
A
A= delete $args{"text"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 777 | 1 | my $wm = PDF::Make::Watermark->text($text, %args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 778 | 1 | my $wms = _watermarks $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 779 | 1 | push @$wms, $wm; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 780 | 1 | _watermarks $self, $wms; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 781 | 1 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 782 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 783 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 784 | # ── Encryption ──────────────────────────────────────────── | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 785 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 786 | 6 | ▶ | sub encrypt { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
encrypt: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 787 | 6 | my ($self, %args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 788 | 6 | _encrypt_args $self, \%args; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 789 | 6 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 790 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 791 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 792 | # ── Layers/OCG ──────────────────────────────────────────── | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 793 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 794 | 2 | ▶ | sub add_layer { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_layer: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 795 | 2 | my ($self, $name, %args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 796 | 2 | my $xs_doc = doc $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 797 | 2 | my $layer = PDF::Make::Layer->create($xs_doc, $name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 798 | 2 | ▶ | $layer->visible($args{visible}) if defined $args{visible}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 799 | 2 | my $num = $layer->write_to_doc($xs_doc); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 800 | 2 | my $cur = page $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 801 | 2 | ▶ | if ($cur) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 802 | 2 | $cur->xs_page->add_ocg($layer->res_name, $num); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 803 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 804 | 2 | my $layers = _layers $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 805 | 2 | $layers->{$name} = $layer; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 806 | 2 | _layers $self, $layers; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 807 | 2 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 808 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 809 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 810 | 1 | ▶ | sub begin_layer { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
begin_layer: called CC=3 SCAR=11.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 811 | 1 | my ($self, $name) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 812 | 1 | my $layers = _layers $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 813 | 1 | ▶ | my $layer = $layers->{$name} // die "PDF::Make::Builder: unknown layer '$name'"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$layers->{$name} // die("PDF::Make::Builder: unknown layer '${name}'")
MC/DC0%0/1
$layers->{$name} // die("PDF::Make::Builder: unknown layer '${name}'")
$layers->{$name}
Truth table50%1/2
A
A= $layers->{$name}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 814 | 1 | my $cur = page $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 815 | 1 | ▶ | die "PDF::Make::Builder: no current page" unless $cur; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 816 | 1 | $cur->canvas->begin_layer($layer->res_name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 817 | 1 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 818 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 819 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 820 | 1 | ▶ | sub end_layer { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
end_layer: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 821 | 1 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 822 | 1 | my $cur = page $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 823 | 1 | ▶ | die "PDF::Make::Builder: no current page" unless $cur; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 824 | 1 | $cur->canvas->end_layer; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 825 | 1 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 826 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 827 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 828 | # ── Redaction ───────────────────────────────────────────── | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 829 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 830 | 6 | ▶ | sub mark_redaction { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
mark_redaction: called CC=14 SCAR=28.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 831 | 6 | my ($self, %args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 832 | 6 | ▶ | my $page_index = delete $args{page} // 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
delete $args{"page"} // 0
MC/DC0%0/1
delete $args{"page"} // 0
delete $args{"page"}
Truth table50%1/2
A
A= delete $args{"page"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 833 | 6 | my $ps = pages $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 834 | 6 | ▶ | die "PDF::Make::Builder: page index out of range" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$page_index >= 0 and $page_index < scalar @$ps
MC/DC0%0/2
$page_index >= 0 and $page_index < scalar @$ps
$page_index >= 0
$page_index < scalar @$ps
Truth table33%1/3
A and B
A= $page_index >= 0B= $page_index < scalar @$ps
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 835 | unless $page_index >= 0 && $page_index < scalar @$ps; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 836 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 837 | 6 | my $bp = $ps->[$page_index]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 838 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 839 | # Register the /Redact annotation for downstream tools. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 840 | 6 | PDF::Make::Redaction->mark($bp->xs_page, %args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 841 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 842 | 6 | ▶ | my $rect = $args{rect} or return $self; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 843 | 6 | my ($x0, $y0, $x1, $y1) = @$rect; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 844 | 6 | my ($w, $h) = ($x1 - $x0, $y1 - $y0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 845 | 6 | ▶ | return $self if $w <= 0 || $h <= 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$w <= 0 or $h <= 0
MC/DC0%0/2
$w <= 0 or $h <= 0
$w <= 0
$h <= 0
Truth table33%1/3
A or B
A= $w <= 0B= $h <= 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 846 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 847 | 6 | ▶ | my $colour = $args{overlay_colour} // $args{overlay_color} // '#000'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition40%2/5
($args{"overlay_colour"} // $args{"overlay_color"}) // "#000"
$args{"overlay_colour"} // $args{"overlay_color"}
MC/DC0%0/2
($args{"overlay_colour"} // $args{"overlay_color"}) // "#000"
$args{"overlay_colour"}
$args{"overlay_color"}
Truth table33%1/3
A // B
A= $args{"overlay_colour"}B= $args{"overlay_color"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 848 | 6 | my $text = $args{overlay_text}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 849 | 6 | ▶ | my $size = $args{overlay_font_size} // 10; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$args{"overlay_font_size"} // 10
MC/DC0%0/1
$args{"overlay_font_size"} // 10
$args{"overlay_font_size"}
Truth table50%1/2
A
A= $args{"overlay_font_size"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 850 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 851 | # Remember the redaction so save-time can rewrite the content stream | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 852 | # to actually remove text that falls inside the rect, then repaint | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 853 | # the overlay on top of the filtered stream. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 854 | 6 | my $list = $bp->redactions; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 855 | 6 | push @$list, { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 856 | rect => [$x0, $y0, $x1, $y1], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 857 | overlay_text => $text, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 858 | overlay_size => $size, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 859 | overlay_fill => $colour, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 860 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 861 | 6 | $bp->redactions($list); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 862 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 863 | # Eagerly paint the opaque cover so that even a user who never calls | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 864 | # apply_redactions sees the sensitive area visually hidden. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 865 | 6 | my $font = $self->font; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 866 | 6 | my ($r, $g, $b) = $font->hex_to_rgb($colour); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 867 | 6 | my $canvas = $bp->canvas; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 868 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 869 | 6 | $canvas->q->rg($r, $g, $b)->re($x0, $y0, $w, $h)->f->Q; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 870 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 871 | 6 | ▶ | if (defined $text && length $text) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $text and length $text
MC/DC50%1/2
defined $text and length $text
defined $text
length $text
Truth table66%2/3
A and B
A= defined $textB= length $text
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 872 | 4 | my $res = $font->ensure_loaded($bp->xs_page, 'normal'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 873 | 4 | my ($tr, $tg, $tb) = $font->hex_to_rgb('#fff'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 874 | 4 | ▶ | my $tw = $font->measure_text($text) * ($size / ($font->size || 9)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$font->size || 9
MC/DC0%0/1
$font->size || 9
$font->size
Truth table50%1/2
A
A= $font->size
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 875 | 4 | my $tx = $x0 + ($w - $tw) / 2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 876 | 4 | ▶ | $tx = $x0 + 4 if $tw > $w - 4; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 877 | 4 | my $ty = $y0 + ($h - $size) / 2 + 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 878 | 4 | my $show = $font->show_op; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 879 | 4 | $canvas->q | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 880 | ->BT | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 881 | ->rg($tr, $tg, $tb) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 882 | ->Tf($res, $size) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 883 | ->Tm(1, 0, 0, 1, $tx, $ty) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 884 | ->$show($font->encode($text)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 885 | ->ET | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 886 | ->Q; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 887 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 888 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 889 | 6 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 890 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 891 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 892 | 2 | ▶ | sub apply_redactions { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
apply_redactions: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 893 | 2 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 894 | 2 | _apply_redactions_pending $self, 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 895 | 2 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 896 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 897 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 898 | 2 | ▶ | sub sanitize { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
sanitize: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 899 | 2 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 900 | 2 | _sanitize_pending $self, 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 901 | 2 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 902 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 903 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 904 | # Internal: filter the canvas bytes for one page through the redaction | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 905 | # rewriter and re-paint overlay text. Called from save() / to_bytes() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 906 | # when $builder->_apply_redactions_pending is set. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 907 | 1 | ▶ | sub _rewrite_redacted_canvas_bytes { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_rewrite_redacted_canvas_bytes: called CC=12 SCAR=26.7
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 908 | 1 | my ($self, $bp) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 909 | 1 | my $reds = $bp->redactions; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 910 | 1 | ▶ | return $bp->canvas->to_bytes unless $reds && @$reds; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$reds and @$reds
MC/DC0%0/2
$reds and @$reds
$reds
@$reds
Truth table33%1/3
A and B
A= $redsB= @$reds
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 911 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 912 | 1 | my $raw_bytes = $bp->canvas->to_bytes; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 913 | 1 | my @rects = map { $_->{rect} } @$reds; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 914 | 1 | my $filtered = PDF::Make::Redaction->rewrite_stream($raw_bytes, \@rects); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 915 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 916 | # Re-paint overlay text for each redaction on a fresh small canvas | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 917 | # so those BT..ET blocks come AFTER the filtered stream and are not | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 918 | # themselves dropped by the filter. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 919 | 1 | my $overlay_canvas = PDF::Make::Canvas->new; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 920 | 1 | my $font = $self->font; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 921 | 1 | for my $r (@$reds) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 922 | 2 | my ($x0, $y0, $x1, $y1) = @{$r->{rect}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 923 | 2 | my ($w, $h) = ($x1 - $x0, $y1 - $y0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 924 | 2 | ▶ | next if $w <= 0 || $h <= 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$w <= 0 or $h <= 0
MC/DC0%0/2
$w <= 0 or $h <= 0
$w <= 0
$h <= 0
Truth table33%1/3
A or B
A= $w <= 0B= $h <= 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 925 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 926 | # Black rect (re-paint since the filter kept the original, but | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 927 | # redundant paints are harmless and guard against any edge case | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 928 | # where the original rect op was adjacent to a dropped block). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 929 | 2 | ▶ | my ($br, $bg, $bb) = $font->hex_to_rgb($r->{overlay_fill} // '#000'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$r->{"overlay_fill"} // "#000"
MC/DC0%0/1
$r->{"overlay_fill"} // "#000"
$r->{"overlay_fill"}
Truth table50%1/2
A
A= $r->{"overlay_fill"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 930 | 2 | $overlay_canvas->q->rg($br, $bg, $bb)->re($x0, $y0, $w, $h)->f->Q; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 931 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 932 | 2 | my $text = $r->{overlay_text}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 933 | 2 | ▶ | next unless defined $text && length $text; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $text and length $text
MC/DC0%0/2
defined $text and length $text
defined $text
length $text
Truth table33%1/3
A and B
A= defined $textB= length $text
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 934 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 935 | 2 | ▶ | my $size = $r->{overlay_size} || 10; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$r->{'overlay_size'} || 10
MC/DC0%0/1
$r->{'overlay_size'} || 10
$r->{'overlay_size'}
Truth table50%1/2
A
A= $r->{'overlay_size'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 936 | 2 | my $res = $font->ensure_loaded($bp->xs_page, 'normal'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 937 | 2 | my ($tr, $tg, $tb) = $font->hex_to_rgb('#fff'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 938 | 2 | ▶ | my $tw = $font->measure_text($text) * ($size / ($font->size || 9)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$font->size || 9
MC/DC0%0/1
$font->size || 9
$font->size
Truth table50%1/2
A
A= $font->size
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 939 | 2 | my $tx = $x0 + ($w - $tw) / 2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 940 | 2 | ▶ | $tx = $x0 + 4 if $tw > $w - 4; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 941 | 2 | my $ty = $y0 + ($h - $size) / 2 + 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 942 | 2 | my $show = $font->show_op; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 943 | 2 | $overlay_canvas->q | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 944 | ->BT | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 945 | ->rg($tr, $tg, $tb) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 946 | ->Tf($res, $size) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 947 | ->Tm(1, 0, 0, 1, $tx, $ty) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 948 | ->$show($font->encode($text)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 949 | ->ET | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 950 | ->Q; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 951 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 952 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 953 | 1 | return $filtered . $overlay_canvas->to_bytes; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 954 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 955 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 956 | # ── Color Management ────────────────────────────────────── | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 957 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 958 | 4 | ▶ | sub set_color_space { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_color_space: called CC=7 SCAR=19.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 959 | 4 | my ($self, $type, %args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 960 | 4 | my $cs; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 961 | 4 | ▶ | if ($type eq 'sRGB') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 962 | 2 | $cs = PDF::Make::Color->srgb; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 963 | } elsif ($type eq 'separation') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 964 | $cs = PDF::Make::Color->separation( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 965 | 1 | ▶ | $args{name}, $args{c} // 0, $args{m} // 0, $args{y} // 0, $args{k} // 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%4/8
$args{"c"} // 0
$args{"m"} // 0
$args{"y"} // 0
$args{"k"} // 0
MC/DC0%0/1
$args{"c"} // 0
$args{"c"}
MC/DC0%0/1
$args{"m"} // 0
$args{"m"}
MC/DC0%0/1
$args{"y"} // 0
$args{"y"}
MC/DC0%0/1
$args{"k"} // 0
$args{"k"}
Truth table50%1/2
A
A= $args{"c"}
Truth table50%1/2
A
A= $args{"m"}
Truth table50%1/2
A
A= $args{"y"}
Truth table50%1/2
A
A= $args{"k"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 966 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 967 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 968 | 1 | die "PDF::Make::Builder: unknown color space '$type'"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 969 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 970 | 3 | my $xs_doc = doc $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 971 | 3 | $cs->write_to_doc($xs_doc); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 972 | 3 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 973 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 974 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 975 | # ── Tagged PDF / Accessibility ──────────────────────────── | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 976 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 977 | 1 | ▶ | sub enable_tagging { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
enable_tagging: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 978 | 1 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 979 | 1 | my $xs_doc = doc $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 980 | 1 | my $tree = PDF::Make::Structure->create_tree($xs_doc); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 981 | 1 | _struct_tree $self, $tree; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 982 | 1 | _tagging $self, 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 983 | 1 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 984 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 985 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 986 | # ── Forms ───────────────────────────────────────────────── | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 987 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 988 | 53 | my %_field_class = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 989 | text => 'PDF::Make::Builder::Form::Field::Text', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 990 | checkbox => 'PDF::Make::Builder::Form::Field::Checkbox', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 991 | radio => 'PDF::Make::Builder::Form::Field::Radio', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 992 | combo => 'PDF::Make::Builder::Form::Field::Combo', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 993 | dropdown => 'PDF::Make::Builder::Form::Field::Combo', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 994 | listbox => 'PDF::Make::Builder::Form::Field::Listbox', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 995 | list => 'PDF::Make::Builder::Form::Field::Listbox', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 996 | button => 'PDF::Make::Builder::Form::Field::Button', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 997 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 998 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 999 | 28 | ▶ | sub add_field { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_field: called CC=31 SCAR=37.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1000 | 28 | my ($self, %args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1001 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1002 | 28 | ▶ | my $type = delete $args{type} // die "PDF::Make::Builder: add_field requires type"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
delete $args{"type"} // die("PDF::Make::Builder: add_field requires type")
MC/DC100%1/1
delete $args{"type"} // die("PDF::Make::Builder: add_field requires type")
delete $args{"type"}
Truth table100%2/2
A
A= delete $args{"type"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1003 | 27 | ▶ | my $name = delete $args{name} // die "PDF::Make::Builder: add_field requires name"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
delete $args{"name"} // die("PDF::Make::Builder: add_field requires name")
MC/DC100%1/1
delete $args{"name"} // die("PDF::Make::Builder: add_field requires name")
delete $args{"name"}
Truth table100%2/2
A
A= delete $args{"name"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1004 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1005 | 26 | ▶ | my $class = $_field_class{$type} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$_field_class{$type} // die("PDF::Make::Builder: unknown field type '${type}'")
MC/DC100%1/1
$_field_class{$type} // die("PDF::Make::Builder: unknown field type '${type}'")
$_field_class{$type}
Truth table100%2/2
A
A= $_field_class{$type}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1006 | // die "PDF::Make::Builder: unknown field type '$type'"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1007 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1008 | # Default to structured mode. Enter raw mode for explicit coordinates | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1009 | # or when requested directly. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1010 | 24 | my $raw_mode = delete $args{raw_mode}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1011 | 24 | ▶ | if (!defined $raw_mode) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1012 | 24 | ▶ | $raw_mode = (exists $args{rect} || exists $args{x} || exists $args{y}) ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
exists $args{"rect"} or exists $args{"x"} or exists $args{"y"}
exists $args{"rect"} or exists $args{"x"}
MC/DC66%2/3
exists $args{"rect"} or exists $args{"x"} or exists $args{"y"}
exists $args{"rect"}
exists $args{"x"}
exists $args{"y"}
Truth table75%3/4
A or B or C
A= exists $args{"rect"}B= exists $args{"x"}C= exists $args{"y"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1013 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1014 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1015 | 24 | ▶ | if (!$raw_mode) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1016 | 15 | ▶ | if (exists $args{default} && !exists $args{default_value}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
exists $args{"default"} and not exists $args{"default_value"}
MC/DC0%0/2
exists $args{"default"} and not exists $args{"default_value"}
exists $args{"default"}
not exists $args{"default_value"}
Truth table33%1/3
A and not(B)
A= exists $args{"default"}B= not exists $args{"default_value"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1017 | 0 | $args{default_value} = delete $args{default}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1018 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1019 | 15 | my $field = $class->new(field_name => $name, %args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1020 | 15 | $field->add($self); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1021 | 15 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1022 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1023 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1024 | # Raw mode (direct widget placement) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1025 | 9 | my $default = delete $args{default}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1026 | 9 | ▶ | $default = delete $args{default_value} unless defined $default; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1027 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1028 | 9 | my $cur = page $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1029 | 9 | ▶ | die "PDF::Make::Builder: no current page" unless $cur; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1030 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1031 | 9 | my ($x, $y, $w, $h); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1032 | 9 | ▶ | if ($args{rect}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1033 | 8 | ($x, $y, $w, $h) = @{delete $args{rect}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1034 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1035 | # Cursor-relative placement like add_text | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1036 | 1 | ▶ | $x = delete $args{x} // $cur->content_x; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
delete $args{"x"} // $cur->content_x
MC/DC0%0/2
delete $args{"x"} // $cur->content_x
delete $args{"x"}
$cur->content_x
Truth table33%1/3
A // B
A= delete $args{"x"}B= $cur->content_x
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1037 | 1 | ▶ | $w = delete $args{w} // $cur->width; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
delete $args{"w"} // $cur->width
MC/DC0%0/2
delete $args{"w"} // $cur->width
delete $args{"w"}
$cur->width
Truth table33%1/3
A // B
A= delete $args{"w"}B= $cur->width
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1038 | 1 | ▶ | $h = delete $args{h} // 22; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
delete $args{"h"} // 22
MC/DC0%0/1
delete $args{"h"} // 22
delete $args{"h"}
Truth table50%1/2
A
A= delete $args{"h"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1039 | 1 | ▶ | if (defined $args{y}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1040 | 0 | $y = delete $args{y}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1041 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1042 | 1 | $y = $cur->cursor_y - $h; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1043 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1044 | # Advance cursor past the field | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1045 | 1 | $cur->advance_y($h + 4); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1046 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1047 | 9 | ▶ | die "PDF::Make::Builder: field requires coordinates" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%3/9
defined $x and defined $y and defined $w and defined $h
defined $x and defined $y and defined $w
defined $x and defined $y
MC/DC0%0/4
defined $x and defined $y and defined $w and defined $h
defined $x
defined $y
defined $w
defined $h
Truth table20%1/5
A and B and C and D
A= defined $xB= defined $yC= defined $wD= defined $h
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1048 | unless defined $x && defined $y && defined $w && defined $h; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1049 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1050 | 9 | my %fargs = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1051 | field_name => $name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1052 | x => $x, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1053 | y => $y, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1054 | w => $w, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1055 | h => $h, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1056 | raw_mode => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1057 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1058 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1059 | 9 | ▶ | $fargs{default_value} = $default if defined $default; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1060 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1061 | 9 | ▶ | $fargs{readonly} = $args{readonly} ? 1 : 0 if exists $args{readonly}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1062 | 9 | ▶ | $fargs{required} = $args{required} ? 1 : 0 if exists $args{required}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1063 | 9 | ▶ | $fargs{da} = $args{da} if exists $args{da}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1064 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1065 | # Field-specific passthrough | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1066 | 9 | ▶ | $fargs{options} = $args{options} if exists $args{options}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1067 | 9 | ▶ | $fargs{caption} = $args{caption} if exists $args{caption}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1068 | 9 | ▶ | $fargs{on_value} = $args{on_value} if exists $args{on_value}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1069 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1070 | 9 | my $field = $class->new(%fargs); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1071 | 9 | $field->add($self); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1072 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1073 | 9 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1074 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1075 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1076 | 2 | ▶ | sub flatten_form { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
flatten_form: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1077 | 2 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1078 | 2 | _flatten_pending $self, 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1079 | 2 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1080 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1081 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1082 | # ── Digital Signatures ──────────────────────────────────── | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1083 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1084 | 1 | ▶ | sub sign { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
sign: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1085 | 1 | my ($self, %args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1086 | 1 | _sign_args $self, \%args; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1087 | 1 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1088 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1089 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1090 | # ── TOC ──────────────────────────────────────────────────── | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1091 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1092 | 5 | ▶ | sub add_toc { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_toc: called CC=4 SCAR=14.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1093 | 5 | my ($self, %args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1094 | 5 | my $cfg = configure $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1095 | 5 | ▶ | my $toc_cfg = $cfg->{toc} // {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$cfg->{"toc"} // {}
MC/DC0%0/1
$cfg->{"toc"} // {}
$cfg->{"toc"}
Truth table50%1/2
A
A= $cfg->{"toc"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1096 | 5 | my $cur = page $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1097 | 5 | ▶ | my $default_toc_page = $cur ? ($cur->num - 1) : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1098 | 5 | %args = (%$toc_cfg, %args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1099 | 5 | ▶ | $args{page_index} = $default_toc_page unless exists $args{page_index}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1100 | 5 | toc $self, PDF::Make::Builder::TOC->new(%args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1101 | 5 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1102 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1103 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1104 | # ── Save ─────────────────────────────────────────────────── | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1105 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1106 | # Everything save() does up to the point where bytes exist: the TOC, the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1107 | # headers and footers, redactions, watermarks and signing. Split out so that | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1108 | # a caller can have the bytes without a file - a render service produces | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1109 | # millions of documents that never want to touch a disk - while save() stays | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1110 | # exactly the sequence it always was. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1111 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1112 | # It draws on the pages, so it must happen once. Calling save() and then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1113 | # to_bytes() renders one document, not one with two sets of headers. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1114 | 525 | ▶ | sub _finalise { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_finalise: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1115 | 525 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1116 | 525 | ▶ | return _signed_cache($self) if _finalised $self; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1117 | 525 | my $signed = $self->_finalise_once; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1118 | 525 | _finalised $self, 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1119 | 525 | _signed_cache $self, $signed; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1120 | 525 | return $signed; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1121 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1122 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1123 | 352 | ▶ | sub to_bytes { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
to_bytes: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1124 | 352 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1125 | 352 | my $signed = $self->_finalise; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1126 | 352 | ▶ | return $signed if defined $signed; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1127 | 352 | return (doc $self)->to_bytes; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1128 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1129 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1130 | 525 | ▶ | sub _finalise_once { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_finalise_once: called CC=31 SCAR=36.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1131 | 525 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1132 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1133 | # Render TOC if present | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1134 | 525 | my $cur = page $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1135 | 525 | ▶ | if ($cur) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1136 | 525 | my $t = toc $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1137 | 525 | ▶ | if ($t && @{$t->entries}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$t and @{$t->entries;}
MC/DC50%1/2
$t and @{$t->entries;}
$t
@{$t->entries;}
Truth table66%2/3
A and B
A= $tB= @{$t->entries;}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1138 | 5 | $t->render($self); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1139 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1140 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1141 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1142 | # Render headers/footers onto each page's canvas, then finalize | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1143 | 525 | my $all_pages = pages $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1144 | 525 | my $offset = page_offset $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1145 | 525 | my $rewrite = _apply_redactions_pending $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1146 | 525 | for my $bp (@$all_pages) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1147 | 574 | ▶ | if ($bp->imported) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1148 | # Imported pages keep their original content, but any overlay | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1149 | # drawing issued against the Builder's canvas (e.g. a box | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1150 | # around extracted text) needs to be appended so it renders | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1151 | # on top of the source graphics. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1152 | 34 | my $overlay = $bp->canvas->to_bytes; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1153 | 34 | ▶ | if (defined $overlay && length $overlay) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $overlay and length $overlay
MC/DC0%0/2
defined $overlay and length $overlay
defined $overlay
length $overlay
Truth table33%1/3
A and B
A= defined $overlayB= length $overlay
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1154 | 0 | $bp->xs_page->append_content($overlay); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1155 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1156 | 34 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1157 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1158 | 540 | my $hdr = $bp->header; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1159 | 540 | my $ftr = $bp->footer; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1160 | 540 | my $pnum = $bp->num + $offset; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1161 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1162 | 540 | ▶ | if ($hdr) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1163 | 20 | $hdr->render($self, $bp, $pnum); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1164 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1165 | 540 | ▶ | if ($ftr) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1166 | 14 | $ftr->render($self, $bp, $pnum); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1167 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1168 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1169 | # Finalize page content; filter through the redaction rewriter | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1170 | # when the user has called apply_redactions. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1171 | 540 | ▶ | my $bytes = ($rewrite && @{$bp->redactions}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$rewrite and @{$bp->redactions;}
MC/DC100%2/2
$rewrite and @{$bp->redactions;}
$rewrite
@{$bp->redactions;}
Truth table100%3/3
A and B
A= $rewriteB= @{$bp->redactions;}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1172 | ? $self->_rewrite_redacted_canvas_bytes($bp) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1173 | : $bp->canvas->to_bytes; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1174 | 540 | $bp->xs_page->set_content($bytes); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1175 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1176 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1177 | # Every content stream is committed, so the set of glyphs each loaded TTF | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1178 | # has to embed is now final. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1179 | 525 | $self->_finalise_embedded_fonts; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1180 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1181 | 525 | ▶ | if (_sanitize_pending $self) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1182 | 1 | PDF::Make::Redaction->sanitize(doc $self); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1183 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1184 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1185 | # Apply deferred watermarks after all page content is set | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1186 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1187 | 525 | my $wms = _watermarks $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1188 | 525 | ▶ | if ($wms && @$wms) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$wms and @$wms
MC/DC50%1/2
$wms and @$wms
$wms
@$wms
Truth table66%2/3
A and B
A= $wmsB= @$wms
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1189 | 1 | my $xs_doc = doc $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1190 | 1 | for my $wm (@$wms) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1191 | 1 | $xs_doc->add_watermark($wm); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1192 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1193 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1194 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1195 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1196 | # Flatten form fields if requested (after set_content so canvas is committed) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1197 | 525 | ▶ | if (_flatten_pending $self) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1198 | 2 | my $xs_doc = doc $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1199 | 2 | my $form = eval { PDF::Make::FormPtr::get($xs_doc) }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1200 | 2 | ▶ | $form->flatten if $form; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1201 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1202 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1203 | # Finalize form if any fields were added | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1204 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1205 | 525 | my $xs_doc = doc $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1206 | 525 | my $form = eval { PDF::Make::FormPtr::get($xs_doc) }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1207 | 525 | ▶ | if ($form) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1208 | 6 | PDF::Make::FormPtr::finalize($form); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1209 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1210 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1211 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1212 | # Apply encryption if configured. The actual /Encrypt dict is built, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1213 | # and per-object encryption applied, inside pdfmake_doc_write. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1214 | 525 | my $enc = _encrypt_args $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1215 | 525 | ▶ | if ($enc) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1216 | 5 | ▶ | my $algo = $enc->{algorithm} // 'AES-256'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$enc->{"algorithm"} // "AES-256"
MC/DC0%0/1
$enc->{"algorithm"} // "AES-256"
$enc->{"algorithm"}
Truth table50%1/2
A
A= $enc->{"algorithm"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1217 | 5 | ▶ | my $user = $enc->{user_password} // $enc->{password} // ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition60%3/5
($enc->{"user_password"} // $enc->{"password"}) // ""
$enc->{"user_password"} // $enc->{"password"}
MC/DC0%0/2
($enc->{"user_password"} // $enc->{"password"}) // ""
$enc->{"user_password"}
$enc->{"password"}
Truth table66%2/3
A // B
A= $enc->{"user_password"}B= $enc->{"password"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1218 | 5 | ▶ | my $owner = $enc->{owner_password} // $user; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$enc->{"owner_password"} // $user
MC/DC0%0/2
$enc->{"owner_password"} // $user
$enc->{"owner_password"}
$user
Truth table66%2/3
A // B
A= $enc->{"owner_password"}B= $user
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1219 | 5 | ▶ | my $perms = $enc->{permissions} // 0xFFFFFFFC; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$enc->{"permissions"} // 4294967292
MC/DC0%0/1
$enc->{"permissions"} // 4294967292
$enc->{"permissions"}
Truth table50%1/2
A
A= $enc->{"permissions"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1220 | 5 | my $xs_doc = doc $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1221 | 5 | $xs_doc->set_encryption($algo, $user, $owner, $perms); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1222 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1223 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1224 | # Apply digital signature if configured. pdfmake_doc_sign returns | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1225 | # the signed PDF bytes (original doc + /Sig dict + PKCS#7 /Contents), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1226 | # so when signing is active we write the returned bytes, not the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1227 | # unsigned doc->to_bytes() output. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1228 | 525 | my $sig = _sign_args $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1229 | 525 | my $signed_bytes; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1230 | 525 | ▶ | if ($sig && $sig->{pkcs12} && -f $sig->{pkcs12}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
$sig and $sig->{"pkcs12"} and -f $sig->{"pkcs12"}
$sig and $sig->{"pkcs12"}
MC/DC0%0/3
$sig and $sig->{"pkcs12"} and -f $sig->{"pkcs12"}
$sig
$sig->{"pkcs12"}
-f $sig->{"pkcs12"}
Truth table50%2/4
A and B and C
A= $sigB= $sig->{"pkcs12"}C= -f $sig->{"pkcs12"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1231 | my $identity = PDF::Make::Signature->load_identity( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1232 | file => $sig->{pkcs12}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1233 | 0 | ▶ | password => $sig->{password} // '', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$sig->{"password"} // ""
MC/DC0%0/1
$sig->{"password"} // ""
$sig->{"password"}
Truth table0%0/2
A
A= $sig->{"password"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1234 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1235 | 0 | ▶ | die "PDF::Make::Builder: sign: identity has no usable signing key" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$identity and $identity->can_sign
MC/DC0%0/2
$identity and $identity->can_sign
$identity
$identity->can_sign
Truth table0%0/3
A and B
A= $identityB= $identity->can_sign
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1236 | unless $identity && $identity->can_sign; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1237 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1238 | 0 | my $xs_doc = doc $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1239 | $signed_bytes = PDF::Make::Signature::_sign_document($xs_doc, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1240 | identity => $identity, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1241 | reason => $sig->{reason}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1242 | location => $sig->{location}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1243 | contact => $sig->{contact}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1244 | name => $sig->{name}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1245 | hash => $sig->{hash}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1246 | timestamp_url => $sig->{timestamp_url}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1247 | tsa_timeout => $sig->{tsa_timeout}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1248 | visible => $sig->{visible}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1249 | page => $sig->{page}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1250 | rect => $sig->{rect}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1251 | appearance => $sig->{appearance}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1252 | 0 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1253 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1254 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1255 | 525 | return $signed_bytes; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1256 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1257 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1258 | 173 | ▶ | sub save { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
save: called CC=8 SCAR=24.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1259 | 173 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1260 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1261 | 173 | my $signed_bytes = $self->_finalise; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1262 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1263 | # Write to file | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1264 | 173 | my $xs_doc = doc $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1265 | 173 | my $fname = file_name $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1266 | 173 | ▶ | $fname .= '.pdf' unless $fname =~ /\.pdf$/i; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1267 | 173 | my $dir = dirname($fname); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1268 | 173 | ▶ | if (defined $dir && length $dir && $dir ne '.') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
defined $dir and length $dir and $dir ne "."
defined $dir and length $dir
MC/DC0%0/3
defined $dir and length $dir and $dir ne "."
defined $dir
length $dir
$dir ne "."
Truth table25%1/4
A and B and C
A= defined $dirB= length $dirC= $dir ne "."
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1269 | 173 | ▶ | make_path($dir) unless -d $dir; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1270 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1271 | 173 | ▶ | if (defined $signed_bytes) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1272 | 0 | ▶ | open my $fh, '>:raw', $fname or die "PDF::Make::Builder: cannot write '$fname': $!"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1273 | 0 | print $fh $signed_bytes; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1274 | 0 | close $fh; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1275 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1276 | 173 | $xs_doc->to_file($fname); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1277 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1278 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1279 | 173 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1280 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1281 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1282 | # ── Onsave callback management ───────────────────────────── | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1283 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1284 | 0 | ▶ | sub onsave { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
onsave: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1285 | 0 | my ($self, $key, $method, %args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1286 | 0 | my $cbs = onsave_cbs $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1287 | 0 | push @$cbs, [$key, $method, %args]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1288 | 0 | onsave_cbs $self, $cbs; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1289 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1290 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1291 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1292 | # ── Text extraction (phase 13) ──────────────────────────── | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1293 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1294 | 1 | ▶ | sub extract_text { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
extract_text: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1295 | 1 | my ($self, $file, $page_index) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1296 | 1 | ▶ | $page_index //= 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$page_index //= 0
MC/DC0%0/1
$page_index //= 0
$page_index
Truth table50%1/2
A
A= $page_index
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1297 | 1 | my $parser = PDF::Make::Parser->from_file($file); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1298 | 1 | return PDF::Make::Extract->extract($parser, $page_index); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1299 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1300 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1301 | 81 | ▶ | sub extract_structured { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
extract_structured: called CC=8 SCAR=20.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1302 | 81 | my ($self, $file, %args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1303 | 81 | ▶ | my $page_index = $args{page} // 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$args{"page"} // 0
MC/DC100%1/1
$args{"page"} // 0
$args{"page"}
Truth table100%2/2
A
A= $args{"page"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1304 | my $include_invisible = exists $args{invisible} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1305 | 81 | ▶ | ? ($args{invisible} ? 1 : 0) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1306 | : 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1307 | 81 | my $parser = PDF::Make::Parser->from_file($file, repair => 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1308 | 81 | $parser->parse; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1309 | 81 | my $reader = PDF::Make::Reader->new($parser); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1310 | 81 | ▶ | if ($reader->is_encrypted && !$reader->is_authenticated) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$reader->is_encrypted and not $reader->is_authenticated
MC/DC100%2/2
$reader->is_encrypted and not $reader->is_authenticated
$reader->is_encrypted
not $reader->is_authenticated
Truth table100%3/3
A and not(B)
A= $reader->is_encryptedB= not $reader->is_authenticated
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1311 | 3 | ▶ | my $pw = $args{password} // ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$args{"password"} // ""
MC/DC0%0/1
$args{"password"} // ""
$args{"password"}
Truth table50%1/2
A
A= $args{"password"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1312 | 3 | my $rc = $reader->set_password($pw); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1313 | 3 | ▶ | die "PDF::Make::Builder: extract_structured: authentication failed for '$file'" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1314 | if $rc < 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1315 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1316 | 81 | my $raw = PDF::Make::Extract->_extract_structured( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1317 | $reader, $page_index, $include_invisible); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1318 | 81 | return PDF::Make::Extract::Result->new(data => $raw); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1319 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1320 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1321 | 2 | ▶ | sub extract_annotations { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
extract_annotations: called CC=6 SCAR=24.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1322 | 2 | my ($self, $file, %args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1323 | 2 | my $parser = PDF::Make::Parser->from_file($file, repair => 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1324 | 2 | $parser->parse; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1325 | 2 | my $reader = PDF::Make::Reader->new($parser); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1326 | 2 | ▶ | if ($reader->is_encrypted && !$reader->is_authenticated) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$reader->is_encrypted and not $reader->is_authenticated
MC/DC0%0/2
$reader->is_encrypted and not $reader->is_authenticated
$reader->is_encrypted
not $reader->is_authenticated
Truth table33%1/3
A and not(B)
A= $reader->is_encryptedB= not $reader->is_authenticated
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1327 | 0 | ▶ | my $pw = $args{password} // ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$args{"password"} // ""
MC/DC0%0/1
$args{"password"} // ""
$args{"password"}
Truth table0%0/2
A
A= $args{"password"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1328 | 0 | my $rc = $reader->set_password($pw); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1329 | 0 | ▶ | die "PDF::Make::Builder: extract_annotations: authentication failed for '$file'" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1330 | if $rc < 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1331 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1332 | 2 | my $list = PDF::Make::Extract->_extract_annotations($reader); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1333 | 2 | ▶ | return wantarray ? @$list : $list; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1334 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1335 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1336 | 2 | ▶ | sub detect_tables { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
detect_tables: called CC=7 SCAR=25.7
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1337 | 2 | my ($self, $file, %args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1338 | 2 | ▶ | my $page_index = $args{page} // 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$args{"page"} // 0
MC/DC0%0/1
$args{"page"} // 0
$args{"page"}
Truth table50%1/2
A
A= $args{"page"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1339 | 2 | my $parser = PDF::Make::Parser->from_file($file, repair => 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1340 | 2 | $parser->parse; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1341 | 2 | my $reader = PDF::Make::Reader->new($parser); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1342 | 2 | ▶ | if ($reader->is_encrypted && !$reader->is_authenticated) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$reader->is_encrypted and not $reader->is_authenticated
MC/DC0%0/2
$reader->is_encrypted and not $reader->is_authenticated
$reader->is_encrypted
not $reader->is_authenticated
Truth table33%1/3
A and not(B)
A= $reader->is_encryptedB= not $reader->is_authenticated
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1343 | 0 | ▶ | my $pw = $args{password} // ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$args{"password"} // ""
MC/DC0%0/1
$args{"password"} // ""
$args{"password"}
Truth table0%0/2
A
A= $args{"password"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1344 | 0 | my $rc = $reader->set_password($pw); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1345 | 0 | ▶ | die "PDF::Make::Builder: detect_tables: authentication failed for '$file'" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1346 | if $rc < 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1347 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1348 | 2 | my $list = PDF::Make::Extract->_detect_tables($reader, $page_index); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1349 | 2 | ▶ | return wantarray ? @$list : $list; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1350 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1351 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1352 | # ── Open existing PDF ──────────────────────────────────── | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1353 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1354 | 11 | ▶ | sub open_existing { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
open_existing: called CC=3 SCAR=11.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1355 | 11 | my ($class, $file, %args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1356 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1357 | 11 | my $password = delete $args{password}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1358 | 11 | ▶ | my $out_file = delete $args{file_name} // $file; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
delete $args{"file_name"} // $file
MC/DC0%0/2
delete $args{"file_name"} // $file
delete $args{"file_name"}
$file
Truth table66%2/3
A // B
A= delete $args{"file_name"}B= $file
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1359 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1360 | 11 | ▶ | die "PDF::Make::Builder: open_existing: file '$file' not found" unless -f $file; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1361 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1362 | 11 | my $self = $class->new(file_name => $out_file, %args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1363 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1364 | # Round-trip the source document: content + resources + dimensions. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1365 | 11 | $self->append_pdf($file, password => $password); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1366 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1367 | 10 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1368 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1369 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1370 | # ── Append pages from another PDF ───────────────────────── | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1371 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1372 | 26 | ▶ | sub append_pdf { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
append_pdf: called CC=12 SCAR=25.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1373 | 26 | my ($self, $file, %args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1374 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1375 | 26 | ▶ | die "PDF::Make::Builder: append_pdf: file '$file' not found" unless -f $file; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1376 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1377 | 25 | my $parser = PDF::Make::Parser->from_file($file, repair => 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1378 | 25 | $parser->parse; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1379 | 25 | my $reader = PDF::Make::Reader->new($parser); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1380 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1381 | 25 | ▶ | if ($reader->is_encrypted && !$reader->is_authenticated) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$reader->is_encrypted and not $reader->is_authenticated
MC/DC100%2/2
$reader->is_encrypted and not $reader->is_authenticated
$reader->is_encrypted
not $reader->is_authenticated
Truth table100%3/3
A and not(B)
A= $reader->is_encryptedB= not $reader->is_authenticated
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1382 | 5 | ▶ | my $pw = $args{password} // ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$args{"password"} // ""
MC/DC0%0/1
$args{"password"} // ""
$args{"password"}
Truth table50%1/2
A
A= $args{"password"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1383 | 5 | my $rc = $reader->set_password($pw); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1384 | 5 | ▶ | die "PDF::Make::Builder: append_pdf: authentication failed for '$file'" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1385 | if $rc < 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1386 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1387 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1388 | 24 | my $xs_doc = doc $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1389 | 24 | my $importer = PDF::Make::Import->new($reader, $xs_doc); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1390 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1391 | 24 | my $count = $reader->page_count; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1392 | 24 | ▶ | my @indices = $args{pages} ? @{$args{pages}} : (0 .. $count - 1); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1393 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1394 | 24 | for my $idx (@indices) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1395 | 45 | ▶ | die "PDF::Make::Builder: append_pdf: page index $idx out of range (file has $count pages)" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$idx >= 0 and $idx < $count
MC/DC50%1/2
$idx >= 0 and $idx < $count
$idx >= 0
$idx < $count
Truth table66%2/3
A and B
A= $idx >= 0B= $idx < $count
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1396 | unless $idx >= 0 && $idx < $count; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1397 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1398 | 44 | my $before = $xs_doc->page_count; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1399 | 44 | my $ok = $importer->import_page($idx); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1400 | 44 | ▶ | unless ($ok) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1401 | 0 | warn "PDF::Make::Builder: append_pdf: failed to import page $idx from '$file'"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1402 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1403 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1404 | 44 | my $after = $xs_doc->page_count; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1405 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1406 | 44 | for my $pi ($before .. $after - 1) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1407 | 44 | my $xs_page = $xs_doc->get_page($pi); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1408 | 44 | my $pages = pages $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1409 | 44 | my $num = scalar(@$pages) + 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1410 | 44 | my $bp = PDF::Make::Builder::Page->new( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1411 | page_size => 'custom', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1412 | background => '#fff', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1413 | columns => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1414 | padding => 20, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1415 | num => $num, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1416 | w => $xs_page->width, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1417 | h => $xs_page->height, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1418 | canvas => PDF::Make::Canvas->new, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1419 | xs_page => $xs_page, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1420 | imported => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1421 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1422 | 44 | push @$pages, $bp; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1423 | 44 | pages $self, $pages; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1424 | 44 | page $self, $bp; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1425 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1426 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1427 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1428 | 23 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1429 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1430 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1431 | 1 | ▶ | sub merge { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
merge: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1432 | 1 | my ($class, $out_file, @inputs) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1433 | 1 | ▶ | die "PDF::Make::Builder::merge: no input files" unless @inputs; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1434 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1435 | 1 | my $b = $class->new(file_name => $out_file); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1436 | 1 | for my $f (@inputs) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1437 | 3 | $b->append_pdf($f); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1438 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1439 | 1 | $b->save; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1440 | 1 | return $b; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1441 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1442 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1443 | # ── Page editing (phase 15) ─────────────────────────────── | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1444 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1445 | 3 | ▶ | sub remove_page { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
remove_page: called CC=5 SCAR=16.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1446 | 3 | my ($self, $index) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1447 | 3 | my $ps = pages $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1448 | 3 | ▶ | die "PDF::Make::Builder: page index out of range" unless $index >= 0 && $index < scalar @$ps; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$index >= 0 and $index < scalar @$ps
MC/DC0%0/2
$index >= 0 and $index < scalar @$ps
$index >= 0
$index < scalar @$ps
Truth table33%1/3
A and B
A= $index >= 0B= $index < scalar @$ps
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1449 | 3 | splice @$ps, $index, 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1450 | # Re-number remaining pages | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1451 | 3 | for my $i (0 .. $#$ps) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1452 | 3 | $ps->[$i]->num($i + 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1453 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1454 | 3 | pages $self, $ps; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1455 | # Switch to last page if current was removed | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1456 | 3 | ▶ | if (scalar @$ps) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1457 | 2 | page $self, $ps->[-1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1458 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1459 | 1 | page $self, undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1460 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1461 | 3 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1462 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1463 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1464 | 1 | ▶ | sub move_page { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
move_page: called CC=6 SCAR=19.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1465 | 1 | my ($self, $from, $to) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1466 | 1 | my $ps = pages $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1467 | 1 | ▶ | die "PDF::Make::Builder: from index out of range" unless $from >= 0 && $from < scalar @$ps; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$from >= 0 and $from < scalar @$ps
MC/DC0%0/2
$from >= 0 and $from < scalar @$ps
$from >= 0
$from < scalar @$ps
Truth table33%1/3
A and B
A= $from >= 0B= $from < scalar @$ps
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1468 | 1 | ▶ | die "PDF::Make::Builder: to index out of range" unless $to >= 0 && $to < scalar @$ps; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$to >= 0 and $to < scalar @$ps
MC/DC0%0/2
$to >= 0 and $to < scalar @$ps
$to >= 0
$to < scalar @$ps
Truth table33%1/3
A and B
A= $to >= 0B= $to < scalar @$ps
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1469 | 1 | my $pg = splice @$ps, $from, 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1470 | 1 | splice @$ps, $to, 0, $pg; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1471 | 1 | for my $i (0 .. $#$ps) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1472 | 3 | $ps->[$i]->num($i + 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1473 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1474 | 1 | pages $self, $ps; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1475 | 1 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1476 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1477 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1478 | 1 | ▶ | sub duplicate_page { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
duplicate_page: called CC=3 SCAR=11.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1479 | 1 | my ($self, $index) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1480 | 1 | my $ps = pages $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1481 | 1 | ▶ | die "PDF::Make::Builder: page index out of range" unless $index >= 0 && $index < scalar @$ps; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$index >= 0 and $index < scalar @$ps
MC/DC0%0/2
$index >= 0 and $index < scalar @$ps
$index >= 0
$index < scalar @$ps
Truth table33%1/3
A and B
A= $index >= 0B= $index < scalar @$ps
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1482 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1483 | 1 | my $src = $ps->[$index]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1484 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1485 | # Finalize source page content | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1486 | 1 | $src->xs_page->set_content($src->canvas->to_bytes); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1487 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1488 | # Create a new page with same dimensions | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1489 | 1 | my $xs_doc = doc $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1490 | 1 | my $xs_page = $xs_doc->add_page($src->w, $src->h); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1491 | 1 | my $canvas = PDF::Make::Canvas->new; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1492 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1493 | 1 | my $bp = PDF::Make::Builder::Page->new( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1494 | page_size => $src->page_size, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1495 | background => $src->background, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1496 | columns => $src->columns, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1497 | padding => $src->padding, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1498 | num => scalar(@$ps) + 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1499 | w => $src->w, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1500 | h => $src->h, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1501 | canvas => $canvas, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1502 | xs_page => $xs_page, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1503 | header => $src->header, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1504 | footer => $src->footer, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1505 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1506 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1507 | 1 | push @$ps, $bp; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1508 | 1 | pages $self, $ps; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1509 | 1 | page $self, $bp; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1510 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1511 | 1 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1512 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1513 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1514 | 4 | ▶ | sub rotate_page { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
rotate_page: called CC=6 SCAR=18.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1515 | 4 | my ($self, $index, $degrees) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1516 | 4 | my $ps = pages $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1517 | 4 | ▶ | die "PDF::Make::Builder: page index out of range" unless $index >= 0 && $index < scalar @$ps; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$index >= 0 and $index < scalar @$ps
MC/DC0%0/2
$index >= 0 and $index < scalar @$ps
$index >= 0
$index < scalar @$ps
Truth table33%1/3
A and B
A= $index >= 0B= $index < scalar @$ps
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1518 | die "PDF::Make::Builder: rotation must be 0, 90, 180, or 270" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1519 | 4 | ▶ | unless grep { $degrees == $_ } (0, 90, 180, 270); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1520 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1521 | # Swap width/height for 90/270 rotation | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1522 | 4 | my $pg = $ps->[$index]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1523 | 4 | ▶ | if ($degrees == 90 || $degrees == 270) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$degrees == 90 or $degrees == 270
MC/DC100%2/2
$degrees == 90 or $degrees == 270
$degrees == 90
$degrees == 270
Truth table100%3/3
A or B
A= $degrees == 90B= $degrees == 270
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1524 | 3 | my ($w, $h) = ($pg->w, $pg->h); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1525 | 3 | $pg->w($h); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1526 | 3 | $pg->h($w); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1527 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1528 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1529 | 4 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1530 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1531 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1532 | # ── Load TrueType font (phase 12) ──────────────────────── | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1533 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1534 | 3 | ▶ | sub load_ttf { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
load_ttf: called CC=8 SCAR=26.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1535 | 3 | my ($self, $path, %args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1536 | 3 | ▶ | die "PDF::Make::Builder::load_ttf: '$path' not found" unless -f $path; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1537 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1538 | 3 | my $font_obj = PDF::Make::Font->from_file($path); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1539 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1540 | # The family name callers select the font by. Defaults to the font's own | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1541 | # PostScript name so load_ttf($path) alone is usable. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1542 | 3 | ▶ | my $name = $args{name} // $args{family} // $font_obj->base_font; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%2/6
($args{"name"} // $args{"family"}) // $font_obj->base_font
$args{"name"} // $args{"family"}
MC/DC0%0/3
($args{"name"} // $args{"family"}) // $font_obj->base_font
$args{"name"}
$args{"family"}
$font_obj->base_font
Truth table25%1/4
A // B // C
A= $args{"name"}B= $args{"family"}C= $font_obj->base_font
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1543 | 3 | ▶ | die "PDF::Make::Builder::load_ttf: cannot name the font in '$path', " | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $name and length $name
MC/DC0%0/2
defined $name and length $name
defined $name
length $name
Truth table33%1/3
A and B
A= defined $nameB= length $name
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1544 | . "pass name => '...'" unless defined $name && length $name; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1545 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1546 | 3 | my $reg = _ttf_fonts $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1547 | 3 | ▶ | if (my $have = $reg->{$name}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1548 | 0 | ▶ | return $self if $have->{path} eq $path; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1549 | 0 | die "PDF::Make::Builder::load_ttf: '$name' is already loaded from " | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1550 | . "'$have->{path}'"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1551 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1552 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1553 | # Deliberately not written to the document here. The embedded font is a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1554 | # subset of the glyphs actually drawn, and none have been drawn yet; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1555 | # _finalise_embedded_fonts writes it once the content streams are done. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1556 | 3 | $reg->{$name} = { font => $font_obj, path => $path, pages => [], obj => 0 }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1557 | 3 | _ttf_fonts $self, $reg; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1558 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1559 | 3 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1560 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1561 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1562 | # Write each loaded TTF to the document and attach it to every page that used | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1563 | # it. Runs during _finalise, after all text is drawn, because the subset is | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1564 | # built from the glyphs the content streams actually reference. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1565 | 525 | ▶ | sub _finalise_embedded_fonts { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_finalise_embedded_fonts: called CC=7 SCAR=19.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1566 | 525 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1567 | 525 | my $reg = _ttf_fonts $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1568 | 525 | ▶ | return unless $reg && %$reg; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$reg and %$reg
MC/DC50%1/2
$reg and %$reg
$reg
%$reg
Truth table66%2/3
A and B
A= $regB= %$reg
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1569 | 3 | my $doc = doc $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1570 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1571 | 3 | for my $name (sort keys %$reg) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1572 | 3 | my $entry = $reg->{$name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1573 | 3 | ▶ | next unless @{ $entry->{pages} }; # loaded but never drawn with | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1574 | 3 | ▶ | $entry->{obj} ||= $entry->{font}->write_to_doc($doc); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$entry->{"obj"} ||= $entry->{"font"}->write_to_doc($doc)
MC/DC0%0/2
$entry->{"obj"} ||= $entry->{"font"}->write_to_doc($doc)
$entry->{"obj"}
$entry->{"font"}->write_to_doc($doc)
Truth table33%1/3
A ||= B
A= $entry->{"obj"}B= $entry->{"font"}->write_to_doc($doc)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1575 | 3 | for my $xs_page (@{ $entry->{pages} }) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1576 | 3 | $xs_page->add_font_ref("F_$name", $entry->{obj}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1577 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1578 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1579 | 3 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1580 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1581 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1582 | 53 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1583 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1584 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||