lib/PDF/Imposition/Schemaduplex2up.pm

filter: Statementstmt 100% 27 / 27 Branchbran 66.6% 4 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 4 / 4 Podpod n/a totaltotal 94.5% 35 / 37 CC 5 SCAR 12.6
CC
5
Cov
94%
_do_impose
5.0
BEGIN
1.0
BEGIN
1.0
CRAP 3.5
« lib/PDF/Imposition/Schema1repeat4.pm ↑ Summary lib/PDF/Imposition/Schema1x4x2cutfoldbind.pm »
1 package PDF::Imposition::Schemaduplex2up;
2  
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use warnings FATAL => 'all';
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 2 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 extends 'PDF::Imposition::Schema2up';
8  
9 =head1 NAME
10  
11 PDF::Imposition::Schemaduplex2up - Imposition schema 2up for duplex printers
12  
13 =head1 SYNOPSIS
14  
15 This class inherit everything from L<PDF::Imposition::Schema2up> and
16 only alters the C<impose> method to rotate the odd pages by 180
17 degrees. Please refer to the parent class for method documentation.
18  
19 =head1 SCHEMA EXPLANATION
20  
21 This is exactly as the C<2up> schema, but the PDF is prepared for
22 duplex printing.
23  
24 RECTO S.1 VERSO S.1
25 +-----+-----+ +-----+-----+
26 | | | | | |
27 | 1R | 8R | | 2 | 7 |
28 | | | | | |
29 +-----+-----+ +-----+-----+
30  
31 RECTO S.2 VERSO S.2
32 +-----+-----+ +-----+-----+
33 | | | | | |
34 | 3R | 6R | | 4 | 5 |
35 | | | | | |
36 +-----+-----+ +-----+-----+
37  
38 =cut
39  
40  
41 1 ▶sub _do_impose {
Subroutine _do_impose: called CC=5 SCAR=16.1
42 1 my $self = shift;
43 # prototype
44 1 $self->out_pdf_obj->mediabox(
45 $self->orig_width * 2,
46 $self->orig_height,
47 );
48 1 my $seq = $self->page_sequence_for_booklet;
49 1 my $count = 0;
50 1 foreach my $p (@$seq) {
51 # loop over the pages
52 4 $count++;
53 4 my $left = $self->get_imported_page($p->[0]);
54 4 my $right = $self->get_imported_page($p->[1]);
55 4 my $page = $self->out_pdf_obj->page();
56 4 my $gfx = $page->gfx();
57 4 ▶ if ($count % 2) {
Branch: 1 branch
BranchTrueFalseTotal
if ($count % 2) 2 2 4
58 2 $gfx->transform (
59 -translate => [$self->orig_width * 2, $self->orig_height ],
60 -rotate => 180,
61 );
62 }
63 4 ▶ if (defined $left) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $left) 4 0 4
64 4 $gfx->formimage($left, 0, 0);
65 }
66 4 ▶ if (defined $right) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $right) 4 0 4
67 4 $gfx->formimage($right, $self->orig_width, 0);
68 }
69 }
70 }
71  
72 2 1;
« lib/PDF/Imposition/Schema1repeat4.pm ↑ Summary lib/PDF/Imposition/Schema1x4x2cutfoldbind.pm »