| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package PDF::Imposition::Schema1x4x2cutfoldbind; |
|
2
|
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
1766
|
use strict; |
|
|
3
|
|
|
|
|
34
|
|
|
|
3
|
|
|
|
|
85
|
|
|
4
|
3
|
|
|
3
|
|
12
|
use warnings; |
|
|
3
|
|
|
|
|
75
|
|
|
|
3
|
|
|
|
|
92
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
3
|
|
|
3
|
|
11
|
use Types::Standard qw/Bool/; |
|
|
3
|
|
|
|
|
3
|
|
|
|
3
|
|
|
|
|
22
|
|
|
7
|
3
|
|
|
3
|
|
1221
|
use namespace::clean; |
|
|
3
|
|
|
|
|
4
|
|
|
|
3
|
|
|
|
|
25
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
3
|
|
|
3
|
|
545
|
use Moo; |
|
|
3
|
|
|
|
|
4
|
|
|
|
3
|
|
|
|
|
20
|
|
|
10
|
|
|
|
|
|
|
with 'PDF::Imposition::Schema'; |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 NAME |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
PDF::Imposition::Schema1x4x2cutfoldbind - 1x4x2cutfoldbind imposition schema |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
use PDF::Imposition::Schema1x4x2cutfoldbind; |
|
19
|
|
|
|
|
|
|
my $imposer = PDF::Imposition::Schema1x4x2cutfoldbind |
|
20
|
|
|
|
|
|
|
->new( |
|
21
|
|
|
|
|
|
|
file => "test.pdf", |
|
22
|
|
|
|
|
|
|
output => "out.pdf", |
|
23
|
|
|
|
|
|
|
); |
|
24
|
|
|
|
|
|
|
$imposer->impose; |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=head1 SCHEMA EXPLANATION |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
+-----+-----+ +-----+-----+ |
|
29
|
|
|
|
|
|
|
| | | | | | |
|
30
|
|
|
|
|
|
|
| 4 | 1 | | 2 | 3 | |
|
31
|
|
|
|
|
|
|
| | | | | | |
|
32
|
|
|
|
|
|
|
+-----+-----+ +-----+-----+ |
|
33
|
|
|
|
|
|
|
| | | | | | |
|
34
|
|
|
|
|
|
|
| 8 | 5 | | 6 | 7 | |
|
35
|
|
|
|
|
|
|
| | | | | | |
|
36
|
|
|
|
|
|
|
+-----+-----+ +-----+-----+ |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
The schema uses fixes signatures of 8 logical pages, layed out on a |
|
39
|
|
|
|
|
|
|
single sheet, printed recto-verso. |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
To get a booklet out of this schema, you first have to B the |
|
42
|
|
|
|
|
|
|
sheets along the x-axys in the middle, then B each half along |
|
43
|
|
|
|
|
|
|
the y-axys, stack them, repeat for each sheet, and finally glue or |
|
44
|
|
|
|
|
|
|
B the spine. (Hence the name of the module). |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
Does it sound weird? Well, kind of. Looks like a lot of manual work. |
|
47
|
|
|
|
|
|
|
But if it works for you, it works for me as well. |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=head1 METHODS |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=head2 cover |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
This schema supports the cover option. |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=cut |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
has cover => (is => 'rw', isa => Bool); |
|
58
|
|
|
|
|
|
|
|
|
59
|
2
|
|
|
2
|
1
|
8
|
sub pages_per_sheet { 8 } |
|
60
|
|
|
|
|
|
|
|
|
61
|
4
|
|
|
4
|
1
|
17
|
sub signature { 8 } |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head1 INTERNALS |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head2 signature |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
Returns 8. |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head2 pages_per_sheet |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
Returns 8. |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head2 cropmarks_options |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
Set inner to false and force the signature to 4 for cropmarks purposes. |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=cut |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub cropmarks_options { |
|
80
|
2
|
|
|
2
|
1
|
16
|
my %options = ( |
|
81
|
|
|
|
|
|
|
top => 1, |
|
82
|
|
|
|
|
|
|
bottom => 1, |
|
83
|
|
|
|
|
|
|
inner => 0, |
|
84
|
|
|
|
|
|
|
outer => 1, |
|
85
|
|
|
|
|
|
|
twoside => 1, |
|
86
|
|
|
|
|
|
|
# for the purpose of the cropping, the signature is 4 |
|
87
|
|
|
|
|
|
|
signature => 4, |
|
88
|
|
|
|
|
|
|
); |
|
89
|
2
|
|
|
|
|
25
|
return %options; |
|
90
|
|
|
|
|
|
|
} |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
sub _do_impose { |
|
93
|
8
|
|
|
8
|
|
15
|
my $self = shift; |
|
94
|
|
|
|
|
|
|
# set the mediabox doubling them |
|
95
|
8
|
|
|
|
|
120
|
$self->out_pdf_obj->mediabox( |
|
96
|
|
|
|
|
|
|
$self->orig_width * 2, |
|
97
|
|
|
|
|
|
|
$self->orig_height * 2, |
|
98
|
|
|
|
|
|
|
); |
|
99
|
8
|
|
|
|
|
938
|
my $total = $self->total_pages; |
|
100
|
8
|
|
|
|
|
176
|
my @pages = (1..$total); |
|
101
|
8
|
100
|
|
|
|
130
|
if ($self->cover) { |
|
102
|
5
|
100
|
|
|
|
44
|
if (my $modulo = $total % 4) { |
|
103
|
3
|
|
|
|
|
6
|
my $blanks = 4 - $modulo; |
|
104
|
3
|
|
|
|
|
6
|
my $last = pop @pages; |
|
105
|
3
|
|
|
|
|
9
|
for (1 .. $blanks) { |
|
106
|
4
|
|
|
|
|
7
|
push @pages, undef; |
|
107
|
|
|
|
|
|
|
} |
|
108
|
3
|
|
|
|
|
5
|
push @pages, $last; |
|
109
|
|
|
|
|
|
|
} |
|
110
|
|
|
|
|
|
|
} |
|
111
|
8
|
|
|
|
|
41
|
while (@pages) { |
|
112
|
14
|
|
|
|
|
1327
|
my ($p1, $p2, $p3, $p4, $p5, $p6, $p7, $p8) = splice @pages, 0, 8; |
|
113
|
14
|
|
|
|
|
51
|
$self->_compose_quadruple($p8, $p5, $p1, $p4); |
|
114
|
14
|
|
|
|
|
2874
|
$self->_compose_quadruple($p6, $p7, $p3, $p2); |
|
115
|
|
|
|
|
|
|
} |
|
116
|
|
|
|
|
|
|
} |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
sub _compose_quadruple { |
|
119
|
28
|
|
|
28
|
|
52
|
my ($self, @seq) = @_; |
|
120
|
28
|
|
|
|
|
37
|
my $chunk; |
|
121
|
28
|
|
|
|
|
499
|
my $page = $self->out_pdf_obj->page; |
|
122
|
28
|
|
|
|
|
8256
|
my $gfx = $page->gfx; |
|
123
|
28
|
|
|
|
|
2837
|
$chunk = $self->get_imported_page($seq[0]); |
|
124
|
28
|
100
|
|
|
|
1509906
|
$gfx->formimage($chunk, 0, 0) if $chunk; |
|
125
|
28
|
|
|
|
|
4007
|
$chunk = $self->get_imported_page($seq[1]); |
|
126
|
28
|
100
|
|
|
|
62160
|
$gfx->formimage($chunk, $self->orig_width, 0) if $chunk; |
|
127
|
28
|
|
|
|
|
3420
|
$chunk = $self->get_imported_page($seq[2]); |
|
128
|
28
|
100
|
|
|
|
240959
|
$gfx->formimage($chunk, $self->orig_width, $self->orig_height) if $chunk; |
|
129
|
28
|
|
|
|
|
5666
|
$chunk = $self->get_imported_page($seq[3]); |
|
130
|
28
|
50
|
|
|
|
105617
|
$gfx->formimage($chunk, 0, $self->orig_height) if $chunk; |
|
131
|
|
|
|
|
|
|
} |
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
1; |
|
134
|
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
|