line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package PDF::Imposition::Schema2x4x2; |
2
|
3
|
|
|
3
|
|
1922
|
use strict; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
84
|
|
3
|
3
|
|
|
3
|
|
10
|
use warnings; |
|
3
|
|
|
|
|
3
|
|
|
3
|
|
|
|
|
71
|
|
4
|
3
|
|
|
3
|
|
10
|
use Moo; |
|
3
|
|
|
|
|
3
|
|
|
3
|
|
|
|
|
22
|
|
5
|
|
|
|
|
|
|
with 'PDF::Imposition::Schema'; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 NAME |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
PDF::Imposition::Schema2x4x2 - fixed size 16 pages on 2 sheets signature schema, with double folding. |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 SYNOPSIS |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
use PDF::Imposition::Schema2x4x2; |
14
|
|
|
|
|
|
|
my $imposer = PDF::Imposition::Schema2x4x2->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
|
|
|
|
|
|
|
Typical usage: print A5 on A3, or A6 on A4, then fold twice and cut |
27
|
|
|
|
|
|
|
the edges. |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
Visualization (the prefix C means logical page disposed |
30
|
|
|
|
|
|
|
upside-down -- rotated 180 degrees): |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
+------+------+ +------+------+ |
34
|
|
|
|
|
|
|
| | | | | | |
35
|
|
|
|
|
|
|
| r9 | r8 | | r7 | r10 | |
36
|
|
|
|
|
|
|
| | | | | | |
37
|
|
|
|
|
|
|
+------+------+ +------+------+ |
38
|
|
|
|
|
|
|
| | | | | | |
39
|
|
|
|
|
|
|
| 16 | 1 | | 2 | 15 | |
40
|
|
|
|
|
|
|
| | | | | | |
41
|
|
|
|
|
|
|
+------+------+ +------+------+ |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
+------+------+ +------+------+ |
44
|
|
|
|
|
|
|
| | | | | | |
45
|
|
|
|
|
|
|
| r11 | r6 | | r5 | r12 | |
46
|
|
|
|
|
|
|
| | | | | | |
47
|
|
|
|
|
|
|
+------+------+ +------+------+ |
48
|
|
|
|
|
|
|
| | | | | | |
49
|
|
|
|
|
|
|
| 14 | 3 | | 4 | 13 | |
50
|
|
|
|
|
|
|
| | | | | | |
51
|
|
|
|
|
|
|
+------+------+ +------+------+ |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
To complete the block of 16 logical pages, blank pages are inserted if |
55
|
|
|
|
|
|
|
needed. |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=cut |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub _do_impose { |
60
|
2
|
|
|
2
|
|
3
|
my $self = shift; |
61
|
|
|
|
|
|
|
# set the mediabox doubling them |
62
|
2
|
|
|
|
|
32
|
$self->out_pdf_obj->mediabox( |
63
|
|
|
|
|
|
|
$self->orig_width * 2, |
64
|
|
|
|
|
|
|
$self->orig_height * 2, |
65
|
|
|
|
|
|
|
); |
66
|
|
|
|
|
|
|
# here we work with fixed signatures of 16, with the module |
67
|
2
|
|
|
|
|
236
|
my $total = $self->total_pages; |
68
|
2
|
|
|
|
|
46
|
my @pages = (1..$total); |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
# loop over the pages and compose the 4 physical pages |
71
|
2
|
|
|
|
|
9
|
while (@pages) { |
72
|
4
|
|
|
|
|
429
|
my ($p1, $p2, $p3, $p4, |
73
|
|
|
|
|
|
|
$p5, $p6, $p7, $p8, |
74
|
|
|
|
|
|
|
$p9, $p10, $p11, $p12, |
75
|
|
|
|
|
|
|
$p13, $p14, $p15, $p16) = splice @pages, 0, 16; |
76
|
|
|
|
|
|
|
# initialize |
77
|
4
|
|
|
|
|
18
|
$self->_compose_quadruple($p16, $p1, $p8, $p9); |
78
|
4
|
|
|
|
|
787
|
$self->_compose_quadruple($p2, $p15, $p10, $p7); |
79
|
4
|
|
|
|
|
790
|
$self->_compose_quadruple($p14, $p3, $p6, $p11); |
80
|
4
|
|
|
|
|
796
|
$self->_compose_quadruple($p4, $p13, $p12, $p5); |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
sub _compose_quadruple { |
85
|
36
|
|
|
36
|
|
74
|
my ($self, @seq) = @_; |
86
|
36
|
|
|
|
|
56
|
my $chunk; |
87
|
36
|
|
|
|
|
638
|
my $page = $self->out_pdf_obj->page; |
88
|
36
|
|
|
|
|
10558
|
my $gfx = $page->gfx; |
89
|
|
|
|
|
|
|
|
90
|
36
|
|
|
|
|
3658
|
$chunk = $self->get_imported_page($seq[0]); |
91
|
36
|
100
|
|
|
|
1224951
|
$gfx->formimage($chunk, 0, 0) if $chunk; |
92
|
|
|
|
|
|
|
|
93
|
36
|
|
|
|
|
6901
|
$chunk = $self->get_imported_page($seq[1]); |
94
|
36
|
100
|
|
|
|
132413
|
$gfx->formimage($chunk, $self->orig_width, 0) if $chunk; |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
# translate |
97
|
36
|
|
|
|
|
6656
|
$gfx->transform ( |
98
|
|
|
|
|
|
|
-translate => [$self->orig_width * 2, |
99
|
|
|
|
|
|
|
$self->orig_height * 2], |
100
|
|
|
|
|
|
|
-rotate => 180, |
101
|
|
|
|
|
|
|
); |
102
|
|
|
|
|
|
|
|
103
|
36
|
|
|
|
|
14570
|
$chunk = $self->get_imported_page($seq[2]); |
104
|
36
|
100
|
|
|
|
133580
|
$gfx->formimage($chunk, 0, 0) if $chunk; |
105
|
|
|
|
|
|
|
|
106
|
36
|
|
|
|
|
6188
|
$chunk = $self->get_imported_page($seq[3]); |
107
|
36
|
100
|
|
|
|
136604
|
$gfx->formimage($chunk, $self->orig_width, 0) if $chunk; |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=head1 INTERNALS |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=head2 pages_per_sheet |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
Returns 8 |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=head2 cropmarks_options |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
Set inner to false and force signature to 16. |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=cut |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
sub cropmarks_options { |
124
|
2
|
|
|
2
|
1
|
15
|
my %options = ( |
125
|
|
|
|
|
|
|
top => 1, |
126
|
|
|
|
|
|
|
bottom => 1, |
127
|
|
|
|
|
|
|
inner => 0, |
128
|
|
|
|
|
|
|
outer => 1, |
129
|
|
|
|
|
|
|
twoside => 1, |
130
|
|
|
|
|
|
|
signature => 16, |
131
|
|
|
|
|
|
|
); |
132
|
2
|
|
|
|
|
24
|
return %options; |
133
|
|
|
|
|
|
|
} |
134
|
|
|
|
|
|
|
|
135
|
2
|
|
|
2
|
1
|
4
|
sub pages_per_sheet { 8 }; |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
1; |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=head1 SEE ALSO |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
L |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=cut |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
|