File Coverage

blib/lib/PDF/Imposition/Schemaduplex2up.pm
Criterion Covered Total %
statement 25 25 100.0
branch 4 6 66.6
condition n/a
subroutine 4 4 100.0
pod n/a
total 33 35 94.2


line stmt bran cond sub pod time code
1             package PDF::Imposition::Schemaduplex2up;
2              
3 2     2   1416 use strict;
  2         5  
  2         90  
4 2     2   13 use warnings FATAL => 'all';
  2         4  
  2         82  
5              
6 2     2   13 use Moo;
  2         5  
  2         16  
7             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 and
16             only alters the C 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             sub _do_impose {
42 1     1   3 my $self = shift;
43             # prototype
44 1         24 $self->out_pdf_obj->mediabox(
45             $self->orig_width * 2,
46             $self->orig_height,
47             );
48 1         198 my $seq = $self->page_sequence_for_booklet;
49 1         3 my $count = 0;
50 1         4 foreach my $p (@$seq) {
51             # loop over the pages
52 4         1167 $count++;
53 4         26 my $left = $self->get_imported_page($p->[0]);
54 4         275534 my $right = $self->get_imported_page($p->[1]);
55 4         17705 my $page = $self->out_pdf_obj->page();
56 4         3398 my $gfx = $page->gfx();
57 4 100       933 if ($count % 2) {
58 2         12 $gfx->transform (
59             -translate => [$self->orig_width * 2, $self->orig_height ],
60             -rotate => 180,
61             );
62             }
63 4 50       1806 if (defined $left) {
64 4         20 $gfx->formimage($left, 0, 0);
65             }
66 4 50       1688 if (defined $right) {
67 4         19 $gfx->formimage($right, $self->orig_width, 0);
68             }
69             }
70             }
71              
72             1;