line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package PDF::Imposition::Schema4up; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
2037
|
use strict; |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
114
|
|
4
|
3
|
|
|
3
|
|
19
|
use warnings FATAL => 'all'; |
|
3
|
|
|
|
|
9
|
|
|
3
|
|
|
|
|
130
|
|
5
|
3
|
|
|
3
|
|
19
|
use Moo; |
|
3
|
|
|
|
|
9
|
|
|
3
|
|
|
|
|
27
|
|
6
|
|
|
|
|
|
|
extends 'PDF::Imposition::Schema2up'; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 NAME |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
PDF::Imposition::Schema4up - Imposition schema 4up (booklet) |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 SYNOPSIS |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
See L. |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=head1 SCHEMA EXPLANATION |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
This schema is basically the same (with the same options and features) |
19
|
|
|
|
|
|
|
of L. But while with the C<2up> schema you |
20
|
|
|
|
|
|
|
get 2 logical pages on each physical page, with the C<4up> you get 4 |
21
|
|
|
|
|
|
|
pages on each side of the sheet. Hence, the signature must be a |
22
|
|
|
|
|
|
|
multiple of 8. |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
To actually use this schema, paper cutting is needed. First print |
25
|
|
|
|
|
|
|
recto-verso, then cut horizontally and put the lower stack on the |
26
|
|
|
|
|
|
|
upper one and proceed as you would with the C<2up>. |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
It's basically a shortcut to save paper if you impose, e.g. A6 on A4. |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
RECTO VERSO |
32
|
|
|
|
|
|
|
+-----+-----+ +-----+-----+ |
33
|
|
|
|
|
|
|
| | | | | | |
34
|
|
|
|
|
|
|
| 8 | 1 | | 2 | 7 | |
35
|
|
|
|
|
|
|
| | | | | | |
36
|
|
|
|
|
|
|
8<----+---->8 8<----+---->8 |
37
|
|
|
|
|
|
|
| | | | | | |
38
|
|
|
|
|
|
|
| 6 | 3 | | 4 | 5 | |
39
|
|
|
|
|
|
|
| | | | | | |
40
|
|
|
|
|
|
|
+-----+-----+ +-----+-----+ |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=head2 INTERNALS |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=head3 pages_per_sheet |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
Always return 8. |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=cut |
50
|
|
|
|
|
|
|
|
51
|
26
|
|
|
26
|
1
|
91
|
sub pages_per_sheet { 8 }; |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub _do_impose { |
54
|
6
|
|
|
6
|
|
16
|
my $self = shift; |
55
|
|
|
|
|
|
|
# each physical page, 4 logical pages, recto-verso = 8 |
56
|
6
|
50
|
|
|
|
24
|
die if $self->pages_per_sheet != 8; |
57
|
6
|
50
|
|
|
|
63
|
if ($self->computed_signature % 8) { |
58
|
0
|
|
|
|
|
0
|
die "Signature must be a multiple of 8!\n"; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
$self->out_pdf_obj->mediabox( |
62
|
6
|
|
|
|
|
160
|
$self->orig_width * 2, |
63
|
|
|
|
|
|
|
$self->orig_height * 2, |
64
|
|
|
|
|
|
|
); |
65
|
|
|
|
|
|
|
# get the 2up sequence |
66
|
6
|
|
|
|
|
1238
|
my @seq = @{ $self->page_sequence_for_booklet }; |
|
6
|
|
|
|
|
62
|
|
67
|
|
|
|
|
|
|
|
68
|
6
|
50
|
|
|
|
32
|
die "Number of pages is off : " . scalar(@seq) . " should be a multiple of 2!" |
69
|
|
|
|
|
|
|
if @seq % 2; |
70
|
6
|
|
|
|
|
21
|
my $half = @seq / 2; |
71
|
|
|
|
|
|
|
|
72
|
6
|
|
|
|
|
25
|
my @upper = splice @seq, 0, $half; |
73
|
6
|
|
|
|
|
20
|
my @lower = splice @seq; |
74
|
|
|
|
|
|
|
|
75
|
6
|
50
|
|
|
|
24
|
die "Odd arrays!" if @upper != @lower; |
76
|
6
|
|
|
|
|
14
|
my @final_seq; |
77
|
6
|
|
66
|
|
|
39
|
while (@upper && @lower) { |
78
|
26
|
|
|
|
|
38
|
push @final_seq, [ @{ shift(@upper) }, @{ shift(@lower) } ]; |
|
26
|
|
|
|
|
42
|
|
|
26
|
|
|
|
|
86
|
|
79
|
|
|
|
|
|
|
} |
80
|
6
|
50
|
33
|
|
|
40
|
die "Odd arrays!" if @upper || @lower; |
81
|
6
|
|
|
|
|
25
|
while (@final_seq) { |
82
|
26
|
|
|
|
|
8592
|
my ($page, $gfx, $chunk); |
83
|
26
|
|
|
|
|
688
|
$page = $self->out_pdf_obj->page; |
84
|
26
|
|
|
|
|
16165
|
$gfx = $page->gfx; |
85
|
26
|
|
|
|
|
5391
|
my ($one, $two, $three, $four) = @{ shift(@final_seq) }; |
|
26
|
|
|
|
|
109
|
|
86
|
26
|
|
|
|
|
140
|
$chunk = $self->get_imported_page($three); |
87
|
26
|
100
|
|
|
|
1177827
|
$gfx->formimage($chunk, 0, 0) if $chunk; |
88
|
|
|
|
|
|
|
|
89
|
26
|
|
|
|
|
10214
|
$chunk = $self->get_imported_page($four); |
90
|
26
|
100
|
|
|
|
589545
|
$gfx->formimage($chunk, $self->orig_width, 0) if $chunk; |
91
|
|
|
|
|
|
|
|
92
|
26
|
|
|
|
|
10048
|
$chunk = $self->get_imported_page($two); |
93
|
26
|
100
|
|
|
|
697758
|
$gfx->formimage($chunk, |
94
|
|
|
|
|
|
|
$self->orig_width, |
95
|
|
|
|
|
|
|
$self->orig_height) if $chunk; |
96
|
|
|
|
|
|
|
|
97
|
26
|
|
|
|
|
10623
|
$chunk = $self->get_imported_page($one); |
98
|
26
|
50
|
|
|
|
175803
|
$gfx->formimage($chunk, |
99
|
|
|
|
|
|
|
0, |
100
|
|
|
|
|
|
|
$self->orig_height) if $chunk; |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
1; |