lib/PDF/Imposition/Schema2x4x1.pm

filter: Statementstmt 91.4% 32 / 35 Branchbran 100% 10 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 71.4% 5 / 7 Podpod 100% 2 / 2 totaltotal 90.7% 49 / 54 CC 6 SCAR 11.0
CC
6
Cov
93%
_compose_quadruple
5.0
_do_impose
2.0
cropmarks_options
2.0
CRAP 3.0
« lib/PDF/Imposition/Schema1x4x2cutfoldbind.pm ↑ Summary lib/PDF/Imposition/Schema2x4x2.pm »
1 package PDF::Imposition::Schema2x4x1;
2 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 with 'PDF::Imposition::Schema';
6  
7 =head1 NAME
8  
9 PDF::Imposition::Schema2x4x1 - fixed size 8 pages on 1 sheet signature schema, with double folding.
10  
11 =head1 SYNOPSIS
12  
13 use PDF::Imposition::Schema2x4x1;
14 my $imposer = PDF::Imposition::Schema2x4x1->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 8 pages, printed recto-verso on 1 sheet.
25  
26 Typical usage: print A5 on A3, or A6 on A4, then fold twice and cut
27 the top edge.
28  
29 Visualization (the prefix C<r> means logical page disposed
30 upside-down -- rotated 180 degrees):
31  
32  
33 +------+------+ +------+------+
34 | | | | | |
35 | r5 | r4 | | r3 | r6 |
36 | | | | | |
37 +------+------+ +------+------+
38 | | | | | |
39 | 8 | 1 | | 2 | 7 |
40 | | | | | |
41 +------+------+ +------+------+
42  
43  
44 To complete the block of 8 logical pages, blank pages are inserted if
45 needed.
46  
47 =cut
48  
49 1 ▶sub _do_impose {
Subroutine _do_impose: called CC=2 SCAR=6.9
50 1 my $self = shift;
51 # set the mediabox doubling them
52 1 $self->out_pdf_obj->mediabox(
53 $self->orig_width * 2,
54 $self->orig_height * 2,
55 );
56 # here we work with fixed signatures of 8, with the module
57 1 my $total = $self->total_pages;
58 1 my @pages = (1..$total);
59  
60 # loop over the pages and compose the 4 physical pages
61 1 ▶ while (@pages) {
Branch: 1 branch
BranchTrueFalseTotal
if (@pages) 3 1 4
62 3 my ($p1, $p2, $p3, $p4,
63 $p5, $p6, $p7, $p8) = splice @pages, 0, 8;
64 # initialize
65 3 $self->_compose_quadruple($p8, $p1, $p4, $p5);
66 3 $self->_compose_quadruple($p2, $p7, $p6, $p3);
67 }
68 }
69  
70 6 ▶sub _compose_quadruple {
Subroutine _compose_quadruple: called CC=5 SCAR=16.1
71 6 my ($self, @seq) = @_;
72 6 my $chunk;
73 6 my $page = $self->out_pdf_obj->page;
74 6 my $gfx = $page->gfx;
75  
76 6 $chunk = $self->get_imported_page($seq[0]);
77 6 ▶ $gfx->formimage($chunk, 0, 0) if $chunk;
Branch: 1 branch
BranchTrueFalseTotal
if $chunk 5 1 6
78  
79 6 $chunk = $self->get_imported_page($seq[1]);
80 6 ▶ $gfx->formimage($chunk, $self->orig_width, 0) if $chunk;
Branch: 1 branch
BranchTrueFalseTotal
if $chunk 5 1 6
81  
82 # translate
83 6 $gfx->transform (
84 -translate => [$self->orig_width * 2,
85 $self->orig_height * 2],
86 -rotate => 180,
87 );
88  
89 6 $chunk = $self->get_imported_page($seq[2]);
90 6 ▶ $gfx->formimage($chunk, 0, 0) if $chunk;
Branch: 1 branch
BranchTrueFalseTotal
if $chunk 4 2 6
91
92 6 $chunk = $self->get_imported_page($seq[3]);
93 6 ▶ $gfx->formimage($chunk, $self->orig_width, 0) if $chunk;
Branch: 1 branch
BranchTrueFalseTotal
if $chunk 4 2 6
94 }
95  
96 =head1 INTERNALS
97  
98 =head2 pages_per_sheet
99  
100 Returns 8
101  
102 =head2 cropmarks_options
103  
104 Set inner to false and force signature to 8.
105  
106 =cut
107  
108  
109 0 ▶sub cropmarks_options {
Subroutine cropmarks_options: not called CC=1 SCAR=6.9
Pod documented
110 0 my %options = (
111 top => 1,
112 bottom => 1,
113 inner => 0,
114 outer => 1,
115 twoside => 1,
116 signature => 8,
117 );
118 0 return %options;
119 }
120  
121 0 ▶sub pages_per_sheet { 8 };
Subroutine pages_per_sheet: not called CC=1 SCAR=6.9
Pod documented
122  
123 2 1;
124  
125 =head1 SEE ALSO
126  
127 L<PDF::Imposition>
128  
129 =head1 LICENSE
130  
131 This program is free software; you can redistribute it and/or modify
132 it under the terms of either: the GNU General Public License as
133 published by the Free Software Foundation; or the Artistic License.
134  
135 =head1 AUTHOR
136  
137 Daniel Drennan ElAwar <drennan@panix.com>
138  
139 =cut
140  
141  
« lib/PDF/Imposition/Schema1x4x2cutfoldbind.pm ↑ Summary lib/PDF/Imposition/Schema2x4x2.pm »