line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package PDF::Imposition::Schema1x4x2cutfoldbind; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
2083
|
use strict; |
|
3
|
|
|
|
|
9
|
|
|
3
|
|
|
|
|
97
|
|
4
|
3
|
|
|
3
|
|
17
|
use warnings; |
|
3
|
|
|
|
|
9
|
|
|
3
|
|
|
|
|
102
|
|
5
|
|
|
|
|
|
|
|
6
|
3
|
|
|
3
|
|
19
|
use Types::Standard qw/Bool/; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
26
|
|
7
|
3
|
|
|
3
|
|
1880
|
use namespace::clean; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
26
|
|
8
|
|
|
|
|
|
|
|
9
|
3
|
|
|
3
|
|
690
|
use Moo; |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
23
|
|
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
|
44
|
sub pages_per_sheet { 8 } |
60
|
|
|
|
|
|
|
|
61
|
4
|
|
|
4
|
1
|
19
|
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
|
17
|
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
|
|
|
|
|
29
|
return %options; |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
sub _do_impose { |
93
|
8
|
|
|
8
|
|
22
|
my $self = shift; |
94
|
|
|
|
|
|
|
# set the mediabox doubling them |
95
|
8
|
|
|
|
|
175
|
$self->out_pdf_obj->mediabox( |
96
|
|
|
|
|
|
|
$self->orig_width * 2, |
97
|
|
|
|
|
|
|
$self->orig_height * 2, |
98
|
|
|
|
|
|
|
); |
99
|
8
|
|
|
|
|
1497
|
my $total = $self->total_pages; |
100
|
8
|
|
|
|
|
238
|
my @pages = (1..$total); |
101
|
8
|
100
|
|
|
|
150
|
if ($self->cover) { |
102
|
5
|
100
|
|
|
|
52
|
if (my $modulo = $total % 4) { |
103
|
3
|
|
|
|
|
7
|
my $blanks = 4 - $modulo; |
104
|
3
|
|
|
|
|
6
|
my $last = pop @pages; |
105
|
3
|
|
|
|
|
9
|
for (1 .. $blanks) { |
106
|
4
|
|
|
|
|
10
|
push @pages, undef; |
107
|
|
|
|
|
|
|
} |
108
|
3
|
|
|
|
|
7
|
push @pages, $last; |
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
} |
111
|
8
|
|
|
|
|
56
|
while (@pages) { |
112
|
14
|
|
|
|
|
2422
|
my ($p1, $p2, $p3, $p4, $p5, $p6, $p7, $p8) = splice @pages, 0, 8; |
113
|
14
|
|
|
|
|
82
|
$self->_compose_quadruple($p8, $p5, $p1, $p4); |
114
|
14
|
|
|
|
|
5239
|
$self->_compose_quadruple($p6, $p7, $p3, $p2); |
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
} |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
sub _compose_quadruple { |
119
|
28
|
|
|
28
|
|
96
|
my ($self, @seq) = @_; |
120
|
28
|
|
|
|
|
63
|
my $chunk; |
121
|
28
|
|
|
|
|
652
|
my $page = $self->out_pdf_obj->page; |
122
|
28
|
|
|
|
|
14702
|
my $gfx = $page->gfx; |
123
|
28
|
|
|
|
|
5359
|
$chunk = $self->get_imported_page($seq[0]); |
124
|
28
|
100
|
|
|
|
2336779
|
$gfx->formimage($chunk, 0, 0) if $chunk; |
125
|
28
|
|
|
|
|
6679
|
$chunk = $self->get_imported_page($seq[1]); |
126
|
28
|
100
|
|
|
|
95430
|
$gfx->formimage($chunk, $self->orig_width, 0) if $chunk; |
127
|
28
|
|
|
|
|
5846
|
$chunk = $self->get_imported_page($seq[2]); |
128
|
28
|
100
|
|
|
|
367348
|
$gfx->formimage($chunk, $self->orig_width, $self->orig_height) if $chunk; |
129
|
28
|
|
|
|
|
10548
|
$chunk = $self->get_imported_page($seq[3]); |
130
|
28
|
50
|
|
|
|
170518
|
$gfx->formimage($chunk, 0, $self->orig_height) if $chunk; |
131
|
|
|
|
|
|
|
} |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
1; |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
|