lib/PDF/Imposition/Schema2x4x2.pm

filter: Statementstmt 100% 37 / 37 Branchbran 100% 10 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 7 / 7 Podpod 100% 2 / 2 totaltotal 100% 56 / 56 CC 6 SCAR 10.4
CC
6
Cov
100%
_compose_quadruple
5.0
_do_impose
2.0
BEGIN
1.0
CRAP 2.8
« lib/PDF/Imposition/Schema2x4x1.pm ↑ Summary lib/PDF/Imposition/Schema1repeat2side.pm »
1 package PDF::Imposition::Schema2x4x2;
2 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 3 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 3 with 'PDF::Imposition::Schema';
6  
7 =head1 NAME
8  
9 PDF::Imposition::Schema2x4x2 - fixed size 16 pages on 2 sheets signature schema, with double folding.
10  
11 =head1 SYNOPSIS
12  
13 use PDF::Imposition::Schema2x4x2;
14 my $imposer = PDF::Imposition::Schema2x4x2->new(
15 file => "test.pdf",
16 output => "out.pdf",
17 );
18 $imposer->impose;
19  
20 The output pdf will be left in C<< $imposer->output >>
21  
22 =head1 SCHEMA EXPLANATION
23  
24 Fixed signature size of 16 pages, printed recto-verso on 2 sheets.
25  
26 Typical usage: print A5 on A3, or A6 on A4, then fold twice and cut
27 the edges.
28  
29 Visualization (the prefix C<r> means logical page disposed
30 upside-down -- rotated 180 degrees):
31  
32  
33 +------+------+ +------+------+
34 | | | | | |
35 | r9 | r8 | | r7 | r10 |
36 | | | | | |
37 +------+------+ +------+------+
38 | | | | | |
39 | 16 | 1 | | 2 | 15 |
40 | | | | | |
41 +------+------+ +------+------+
42  
43 +------+------+ +------+------+
44 | | | | | |
45 | r11 | r6 | | r5 | r12 |
46 | | | | | |
47 +------+------+ +------+------+
48 | | | | | |
49 | 14 | 3 | | 4 | 13 |
50 | | | | | |
51 +------+------+ +------+------+
52  
53  
54 To complete the block of 16 logical pages, blank pages are inserted if
55 needed.
56  
57 =cut
58  
59 2 ▶sub _do_impose {
Subroutine _do_impose: called CC=2 SCAR=6.9
60 2 my $self = shift;
61 # set the mediabox doubling them
62 2 $self->out_pdf_obj->mediabox(
63 $self->orig_width * 2,
64 $self->orig_height * 2,
65 );
66 # here we work with fixed signatures of 16, with the module
67 2 my $total = $self->total_pages;
68 2 my @pages = (1..$total);
69  
70 # loop over the pages and compose the 4 physical pages
71 2 ▶ while (@pages) {
Branch: 1 branch
BranchTrueFalseTotal
if (@pages) 4 2 6
72 4 my ($p1, $p2, $p3, $p4,
73 $p5, $p6, $p7, $p8,
74 $p9, $p10, $p11, $p12,
75 $p13, $p14, $p15, $p16) = splice @pages, 0, 16;
76 # initialize
77 4 $self->_compose_quadruple($p16, $p1, $p8, $p9);
78 4 $self->_compose_quadruple($p2, $p15, $p10, $p7);
79 4 $self->_compose_quadruple($p14, $p3, $p6, $p11);
80 4 $self->_compose_quadruple($p4, $p13, $p12, $p5);
81 }
82 }
83  
84 36 ▶sub _compose_quadruple {
Subroutine _compose_quadruple: called CC=5 SCAR=16.1
85 36 my ($self, @seq) = @_;
86 36 my $chunk;
87 36 my $page = $self->out_pdf_obj->page;
88 36 my $gfx = $page->gfx;
89  
90 36 $chunk = $self->get_imported_page($seq[0]);
91 36 ▶ $gfx->formimage($chunk, 0, 0) if $chunk;
Branch: 1 branch
BranchTrueFalseTotal
if $chunk 32 4 36
92  
93 36 $chunk = $self->get_imported_page($seq[1]);
94 36 ▶ $gfx->formimage($chunk, $self->orig_width, 0) if $chunk;
Branch: 1 branch
BranchTrueFalseTotal
if $chunk 33 3 36
95  
96 # translate
97 36 $gfx->transform (
98 -translate => [$self->orig_width * 2,
99 $self->orig_height * 2],
100 -rotate => 180,
101 );
102  
103 36 $chunk = $self->get_imported_page($seq[2]);
104 36 ▶ $gfx->formimage($chunk, 0, 0) if $chunk;
Branch: 1 branch
BranchTrueFalseTotal
if $chunk 32 4 36
105
106 36 $chunk = $self->get_imported_page($seq[3]);
107 36 ▶ $gfx->formimage($chunk, $self->orig_width, 0) if $chunk;
Branch: 1 branch
BranchTrueFalseTotal
if $chunk 32 4 36
108 }
109  
110 =head1 INTERNALS
111  
112 =head2 pages_per_sheet
113  
114 Returns 8
115  
116 =head2 cropmarks_options
117  
118 Set inner to false and force signature to 16.
119  
120 =cut
121  
122  
123 2 ▶sub cropmarks_options {
Subroutine cropmarks_options: called CC=1 SCAR=0.0
Pod documented
124 2 my %options = (
125 top => 1,
126 bottom => 1,
127 inner => 0,
128 outer => 1,
129 twoside => 1,
130 signature => 16,
131 );
132 2 return %options;
133 }
134  
135 2 ▶sub pages_per_sheet { 8 };
Subroutine pages_per_sheet: called CC=1 SCAR=0.0
Pod documented
136  
137 3 1;
138  
139 =head1 SEE ALSO
140  
141 L<PDF::Imposition>
142  
143 =cut
144  
145  
« lib/PDF/Imposition/Schema2x4x1.pm ↑ Summary lib/PDF/Imposition/Schema1repeat2side.pm »