line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package PDF::Imposition::Schema2x4x2; |
2
|
3
|
|
|
3
|
|
2583
|
use strict; |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
108
|
|
3
|
3
|
|
|
3
|
|
19
|
use warnings; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
95
|
|
4
|
3
|
|
|
3
|
|
20
|
use Moo; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
33
|
|
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
|
|
8
|
my $self = shift; |
61
|
|
|
|
|
|
|
# set the mediabox doubling them |
62
|
2
|
|
|
|
|
43
|
$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
|
|
|
|
|
421
|
my $total = $self->total_pages; |
68
|
2
|
|
|
|
|
74
|
my @pages = (1..$total); |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
# loop over the pages and compose the 4 physical pages |
71
|
2
|
|
|
|
|
12
|
while (@pages) { |
72
|
4
|
|
|
|
|
949
|
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
|
|
|
|
|
29
|
$self->_compose_quadruple($p16, $p1, $p8, $p9); |
78
|
4
|
|
|
|
|
1707
|
$self->_compose_quadruple($p2, $p15, $p10, $p7); |
79
|
4
|
|
|
|
|
1631
|
$self->_compose_quadruple($p14, $p3, $p6, $p11); |
80
|
4
|
|
|
|
|
1649
|
$self->_compose_quadruple($p4, $p13, $p12, $p5); |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
sub _compose_quadruple { |
85
|
36
|
|
|
36
|
|
157
|
my ($self, @seq) = @_; |
86
|
36
|
|
|
|
|
98
|
my $chunk; |
87
|
36
|
|
|
|
|
912
|
my $page = $self->out_pdf_obj->page; |
88
|
36
|
|
|
|
|
32849
|
my $gfx = $page->gfx; |
89
|
|
|
|
|
|
|
|
90
|
36
|
|
|
|
|
7888
|
$chunk = $self->get_imported_page($seq[0]); |
91
|
36
|
100
|
|
|
|
1988182
|
$gfx->formimage($chunk, 0, 0) if $chunk; |
92
|
|
|
|
|
|
|
|
93
|
36
|
|
|
|
|
14255
|
$chunk = $self->get_imported_page($seq[1]); |
94
|
36
|
100
|
|
|
|
255526
|
$gfx->formimage($chunk, $self->orig_width, 0) if $chunk; |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
# translate |
97
|
36
|
|
|
|
|
14076
|
$gfx->transform ( |
98
|
|
|
|
|
|
|
-translate => [$self->orig_width * 2, |
99
|
|
|
|
|
|
|
$self->orig_height * 2], |
100
|
|
|
|
|
|
|
-rotate => 180, |
101
|
|
|
|
|
|
|
); |
102
|
|
|
|
|
|
|
|
103
|
36
|
|
|
|
|
31732
|
$chunk = $self->get_imported_page($seq[2]); |
104
|
36
|
100
|
|
|
|
255625
|
$gfx->formimage($chunk, 0, 0) if $chunk; |
105
|
|
|
|
|
|
|
|
106
|
36
|
|
|
|
|
13003
|
$chunk = $self->get_imported_page($seq[3]); |
107
|
36
|
100
|
|
|
|
263257
|
$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
|
25
|
my %options = ( |
125
|
|
|
|
|
|
|
top => 1, |
126
|
|
|
|
|
|
|
bottom => 1, |
127
|
|
|
|
|
|
|
inner => 0, |
128
|
|
|
|
|
|
|
outer => 1, |
129
|
|
|
|
|
|
|
twoside => 1, |
130
|
|
|
|
|
|
|
signature => 16, |
131
|
|
|
|
|
|
|
); |
132
|
2
|
|
|
|
|
42
|
return %options; |
133
|
|
|
|
|
|
|
} |
134
|
|
|
|
|
|
|
|
135
|
2
|
|
|
2
|
1
|
8
|
sub pages_per_sheet { 8 }; |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
1; |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=head1 SEE ALSO |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
L |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=cut |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
|