File Coverage

blib/lib/PDF/Imposition/Schemaea4x4.pm
Criterion Covered Total %
statement 19 19 100.0
branch n/a
condition n/a
subroutine 4 4 100.0
pod n/a
total 23 23 100.0


line stmt bran cond sub pod time code
1             package PDF::Imposition::Schemaea4x4;
2 3     3   2314 use strict;
  3         9  
  3         114  
3 3     3   17 use warnings;
  3         8  
  3         98  
4 3     3   18 use Moo;
  3         6  
  3         27  
5             extends 'PDF::Imposition::Schema2x4x2';
6              
7             =head1 NAME
8              
9             PDF::Imposition::Schemaea4x4 - fixed size 16 pages on 2 sheets, with double individual folding
10              
11             =head1 SYNOPSIS
12              
13             use PDF::Imposition::Schemaea4x4;
14             my $imposer = PDF::Imposition::Schemaea4x4->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             This is B suitable for home-printing.
27              
28             Scenario: the sheets are printed. Each sheet is folded B
29             twice. Then the two folded sheets are inserted one into the other, and
30             finally the signature is bound and trimmed.
31              
32             The bounding, to be stable, has to be done by a dedicated machine.
33              
34             Long story short: if you are not looking exactly for this schema, it's
35             not what you want.
36              
37              
38             +------+------+ +------+------+
39             | | | | | |
40             | r13 | r4 | | r3 | r14 |
41             | | | | | |
42             +------+------+ +------+------+
43             | | | | | |
44             | 16 | 1 | | 2 | 15 |
45             | | | | | |
46             +------+------+ +------+------+
47              
48             +------+------+ +------+------+
49             | | | | | |
50             | r9 | r8 | | r7 | r10 |
51             | | | | | |
52             +------+------+ +------+------+
53             | | | | | |
54             | 12 | 5 | | 6 | 11 |
55             | | | | | |
56             +------+------+ +------+------+
57              
58              
59             To complete the block of 16 logical pages, blank pages are inserted if
60             needed.
61              
62             =cut
63              
64             sub _do_impose {
65 3     3   9 my $self = shift;
66 3         68 $self->out_pdf_obj->mediabox(
67             $self->orig_width * 2,
68             $self->orig_height * 2,
69             );
70 3         676 my $total = $self->total_pages;
71 3         131 my @pages = (1..$total);
72 3         18 while (@pages) {
73 5         899 my ($p1, $p2, $p3, $p4,
74             $p5, $p6, $p7, $p8,
75             $p9, $p10, $p11, $p12,
76             $p13, $p14, $p15, $p16) = splice @pages, 0, 16;
77             # initialize
78 5         44 $self->_compose_quadruple($p16, $p1, $p4, $p13);
79 5         1688 $self->_compose_quadruple($p2, $p15, $p14, $p3);
80 5         1830 $self->_compose_quadruple($p12, $p5, $p8, $p9 );
81 5         1735 $self->_compose_quadruple($p6, $p11, $p10, $p7);
82             }
83             }
84              
85             1;