lib/PDF/Imposition/Schema1x4x2cutfoldbind.pm

filter: Statementstmt 100% 49 / 49 Branchbran 92.8% 13 / 14 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 10 / 10 Podpod 100% 3 / 3 totaltotal 98.6% 75 / 76 CC 9 SCAR 11.7
CC
9
Cov
98%
_compose_quadruple
5.0
_do_impose
5.0
BEGIN
1.0
CRAP 3.2
« lib/PDF/Imposition/Schemaduplex2up.pm ↑ Summary lib/PDF/Imposition/Schema2x4x1.pm »
1 package PDF::Imposition::Schema1x4x2cutfoldbind;
2  
3 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 3 ▶use Types::Standard qw/Bool/;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 3 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 3 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 3 with 'PDF::Imposition::Schema';
11  
12 =head1 NAME
13  
14 PDF::Imposition::Schema1x4x2cutfoldbind - 1x4x2cutfoldbind imposition schema
15  
16 =head1 SYNOPSIS
17  
18 use PDF::Imposition::Schema1x4x2cutfoldbind;
19 my $imposer = PDF::Imposition::Schema1x4x2cutfoldbind
20 ->new(
21 file => "test.pdf",
22 output => "out.pdf",
23 );
24 $imposer->impose;
25  
26 =head1 SCHEMA EXPLANATION
27  
28 +-----+-----+ +-----+-----+
29 | | | | | |
30 | 4 | 1 | | 2 | 3 |
31 | | | | | |
32 +-----+-----+ +-----+-----+
33 | | | | | |
34 | 8 | 5 | | 6 | 7 |
35 | | | | | |
36 +-----+-----+ +-----+-----+
37  
38 The schema uses fixes signatures of 8 logical pages, layed out on a
39 single sheet, printed recto-verso.
40  
41 To get a booklet out of this schema, you first have to B<cut> the
42 sheets along the x-axys in the middle, then B<fold> each half along
43 the y-axys, stack them, repeat for each sheet, and finally glue or
44 B<bind> the spine. (Hence the name of the module).
45  
46 Does it sound weird? Well, kind of. Looks like a lot of manual work.
47 But if it works for you, it works for me as well.
48  
49 =head1 METHODS
50  
51 =head2 cover
52  
53 This schema supports the cover option.
54  
55 =cut
56  
57 3 has cover => (is => 'rw', isa => Bool);
58  
59 2 ▶sub pages_per_sheet { 8 }
Subroutine pages_per_sheet: called CC=1 SCAR=0.0
Pod documented
60  
61 4 ▶sub signature { 8 }
Subroutine signature: called CC=1 SCAR=0.0
Pod documented
62  
63 =head1 INTERNALS
64  
65 =head2 signature
66  
67 Returns 8.
68  
69 =head2 pages_per_sheet
70  
71 Returns 8.
72  
73 =head2 cropmarks_options
74  
75 Set inner to false and force the signature to 4 for cropmarks purposes.
76  
77 =cut
78  
79 2 ▶sub cropmarks_options {
Subroutine cropmarks_options: called CC=1 SCAR=0.0
Pod documented
80 2 my %options = (
81 top => 1,
82 bottom => 1,
83 inner => 0,
84 outer => 1,
85 twoside => 1,
86 # for the purpose of the cropping, the signature is 4
87 signature => 4,
88 );
89 2 return %options;
90 }
91  
92 8 ▶sub _do_impose {
Subroutine _do_impose: called CC=5 SCAR=16.1
93 8 my $self = shift;
94 # set the mediabox doubling them
95 8 $self->out_pdf_obj->mediabox(
96 $self->orig_width * 2,
97 $self->orig_height * 2,
98 );
99 8 my $total = $self->total_pages;
100 8 my @pages = (1..$total);
101 8 ▶ if ($self->cover) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->cover) 5 3 8
102 5 ▶ if (my $modulo = $total % 4) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $modulo = $total % 4) 3 2 5
103 3 my $blanks = 4 - $modulo;
104 3 my $last = pop @pages;
105 3 for (1 .. $blanks) {
106 4 push @pages, undef;
107 }
108 3 push @pages, $last;
109 }
110 }
111 8 ▶ while (@pages) {
Branch: 1 branch
BranchTrueFalseTotal
if (@pages) 14 8 22
112 14 my ($p1, $p2, $p3, $p4, $p5, $p6, $p7, $p8) = splice @pages, 0, 8;
113 14 $self->_compose_quadruple($p8, $p5, $p1, $p4);
114 14 $self->_compose_quadruple($p6, $p7, $p3, $p2);
115 }
116 }
117  
118 28 ▶sub _compose_quadruple {
Subroutine _compose_quadruple: called CC=5 SCAR=16.1
119 28 my ($self, @seq) = @_;
120 28 my $chunk;
121 28 my $page = $self->out_pdf_obj->page;
122 28 my $gfx = $page->gfx;
123 28 $chunk = $self->get_imported_page($seq[0]);
124 28 ▶ $gfx->formimage($chunk, 0, 0) if $chunk;
Branch: 1 branch
BranchTrueFalseTotal
if $chunk 17 11 28
125 28 $chunk = $self->get_imported_page($seq[1]);
126 28 ▶ $gfx->formimage($chunk, $self->orig_width, 0) if $chunk;
Branch: 1 branch
BranchTrueFalseTotal
if $chunk 16 12 28
127 28 $chunk = $self->get_imported_page($seq[2]);
128 28 ▶ $gfx->formimage($chunk, $self->orig_width, $self->orig_height) if $chunk;
Branch: 1 branch
BranchTrueFalseTotal
if $chunk 27 1 28
129 28 $chunk = $self->get_imported_page($seq[3]);
130 28 ▶ $gfx->formimage($chunk, 0, $self->orig_height) if $chunk;
Branch: 1 branch
BranchTrueFalseTotal
if $chunk 28 0 28
131 }
132  
133 3 1;
134  
135  
136  
137  
138  
« lib/PDF/Imposition/Schemaduplex2up.pm ↑ Summary lib/PDF/Imposition/Schema2x4x1.pm »