line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package PDF::Imposition::Schema2side; |
2
|
3
|
|
|
3
|
|
2394
|
use strict; |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
197
|
|
3
|
3
|
|
|
3
|
|
20
|
use warnings; |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
98
|
|
4
|
3
|
|
|
3
|
|
49
|
use Moo; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
31
|
|
5
|
|
|
|
|
|
|
with 'PDF::Imposition::Schema'; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 NAME |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
PDF::Imposition::Schema2side - Imposition schema 2side |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 SYNOPSIS |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
use PDF::Imposition::Schema2side; |
14
|
|
|
|
|
|
|
my $imposer = PDF::Imposition::Schema2side->new( |
15
|
|
|
|
|
|
|
file => "test.pdf", |
16
|
|
|
|
|
|
|
output => "out.pdf", |
17
|
|
|
|
|
|
|
); |
18
|
|
|
|
|
|
|
$imposer->impose; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
The output pdf will be in C<$imposer->output> |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=head1 SCHEMA EXPLANATION |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
This schema is straightforward: it just packs 2 consecutives logical |
25
|
|
|
|
|
|
|
pages on a physical one. Example usage: you have a A5 pdf, but you |
26
|
|
|
|
|
|
|
don't want to bother creating a booklet and you just need not to waste |
27
|
|
|
|
|
|
|
paper on your A4 printer. |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
This corresponds to C in the . |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
Page 1 Page 2 |
33
|
|
|
|
|
|
|
+-----+-----+ +-----+-----+ |
34
|
|
|
|
|
|
|
| | | | | | |
35
|
|
|
|
|
|
|
| 1 | 2 | | 3 | 4 | |
36
|
|
|
|
|
|
|
| | | | | | |
37
|
|
|
|
|
|
|
+-----+-----+ +-----+-----+ |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
Page 3 Page 4 |
40
|
|
|
|
|
|
|
+-----+-----+ +-----+-----+ |
41
|
|
|
|
|
|
|
| | | | | | |
42
|
|
|
|
|
|
|
| 5 | 6 | | 7 | 8 | |
43
|
|
|
|
|
|
|
| | | | | | |
44
|
|
|
|
|
|
|
+-----+-----+ +-----+-----+ |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
The last logical page will be empty if the number of pages of the |
47
|
|
|
|
|
|
|
original PDF is odd. |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=cut |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub _do_impose { |
52
|
2
|
|
|
2
|
|
7
|
my $self = shift; |
53
|
2
|
|
|
|
|
42
|
$self->out_pdf_obj->mediabox( |
54
|
|
|
|
|
|
|
$self->orig_width * 2, |
55
|
|
|
|
|
|
|
$self->orig_height, |
56
|
|
|
|
|
|
|
); |
57
|
2
|
|
|
|
|
420
|
my $total = $self->total_pages; |
58
|
2
|
|
|
|
|
69
|
my ($page, $gfx, $chunk); |
59
|
2
|
|
|
|
|
10
|
my @pages = (1..$total); |
60
|
2
|
|
|
|
|
10
|
while (@pages) { |
61
|
8
|
|
|
|
|
2632
|
$page = $self->out_pdf_obj->page; |
62
|
8
|
|
|
|
|
7388
|
$gfx = $page->gfx; |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
# first |
65
|
8
|
|
|
|
|
1717
|
$chunk = $self->get_imported_page(shift(@pages)); |
66
|
8
|
50
|
|
|
|
796985
|
$gfx->formimage($chunk, 0, 0) if $chunk; |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
# second |
69
|
8
|
|
|
|
|
3516
|
$chunk = $self->get_imported_page(shift(@pages)); |
70
|
8
|
100
|
|
|
|
53939
|
$gfx->formimage($chunk, $self->orig_width, 0) if $chunk; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head1 INTERNALS |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head2 pages_per_sheet |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
Returns 4 |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head2 cropmarks_options |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
Set outer to false and force signature to 4. |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=cut |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
sub cropmarks_options { |
88
|
1
|
|
|
1
|
1
|
10
|
my %options = ( |
89
|
|
|
|
|
|
|
top => 1, |
90
|
|
|
|
|
|
|
bottom => 1, |
91
|
|
|
|
|
|
|
inner => 1, |
92
|
|
|
|
|
|
|
outer => 0, |
93
|
|
|
|
|
|
|
twoside => 1, |
94
|
|
|
|
|
|
|
signature => 4, |
95
|
|
|
|
|
|
|
); |
96
|
1
|
|
|
|
|
17
|
return %options; |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
|
99
|
1
|
|
|
1
|
1
|
4
|
sub pages_per_sheet { 4 }; |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
1; |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=head1 SEE ALSO |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
L |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=cut |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
|