| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package PDF::Imposition::Schema1x1; |
|
2
|
3
|
|
|
3
|
|
2336
|
use strict; |
|
|
3
|
|
|
|
|
11
|
|
|
|
3
|
|
|
|
|
110
|
|
|
3
|
3
|
|
|
3
|
|
17
|
use warnings; |
|
|
3
|
|
|
|
|
9
|
|
|
|
3
|
|
|
|
|
123
|
|
|
4
|
|
|
|
|
|
|
|
|
5
|
3
|
|
|
3
|
|
25
|
use Types::Standard qw/Bool/; |
|
|
3
|
|
|
|
|
8
|
|
|
|
3
|
|
|
|
|
64
|
|
|
6
|
3
|
|
|
3
|
|
2648
|
use namespace::clean; |
|
|
3
|
|
|
|
|
6
|
|
|
|
3
|
|
|
|
|
43
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
3
|
|
|
3
|
|
884
|
use Moo; |
|
|
3
|
|
|
|
|
9
|
|
|
|
3
|
|
|
|
|
37
|
|
|
10
|
|
|
|
|
|
|
with "PDF::Imposition::Schema"; |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 NAME |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
PDF::Imposition::Schema1x1 - 1:1 Imposition schema |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head2 SYNOPSIS |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
use PDF::Imposition::Schema1x1; |
|
20
|
|
|
|
|
|
|
my $imposer = PDF::Imposition::Schema2up->new( |
|
21
|
|
|
|
|
|
|
signature => "10-20", |
|
22
|
|
|
|
|
|
|
file => "test.pdf", |
|
23
|
|
|
|
|
|
|
output => "out.pdf", |
|
24
|
|
|
|
|
|
|
cover => 1, |
|
25
|
|
|
|
|
|
|
pages_per_sheet => 4, |
|
26
|
|
|
|
|
|
|
); |
|
27
|
|
|
|
|
|
|
$imposer->impose; |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
The output pdf will be in C<$imposer->output> |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=head1 SCHEMA EXPLANATION |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
This is a 1:1 imposition schema, meaning that apparently doesn't do anything. |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
The purpose of this module is to do 2 things: |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=over 4 |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=item Convert the PDF to version 1.4, if not already so. |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=item Handle the signature rounding and optimization |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
This for example means that a pdf with 6 pages will end up with 8 |
|
44
|
|
|
|
|
|
|
pages (6 + 2 empty), and if you pass the C option with a true |
|
45
|
|
|
|
|
|
|
value, you'll get the sixth page as page 8. |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
Also you can get the computed value calling C and |
|
48
|
|
|
|
|
|
|
the total output pages with C. |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=back |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
If you don't need any of this, you don't have any reason to use this |
|
53
|
|
|
|
|
|
|
module. |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head2 cover |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
This schema supports the cover option. |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=cut |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
has cover => (is => 'rw', isa => Bool); |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub _do_impose { |
|
64
|
7
|
|
|
7
|
|
20
|
my $self = shift; |
|
65
|
7
|
|
|
|
|
139
|
$self->out_pdf_obj->mediabox( |
|
66
|
|
|
|
|
|
|
$self->orig_width, |
|
67
|
|
|
|
|
|
|
$self->orig_height, |
|
68
|
|
|
|
|
|
|
); |
|
69
|
7
|
|
|
|
|
1498
|
my $total_pages = $self->total_pages; |
|
70
|
7
|
|
|
|
|
262
|
my $signature = $self->computed_signature; |
|
71
|
7
|
|
|
|
|
34
|
my $max_page = $self->total_output_pages; |
|
72
|
7
|
|
|
|
|
21
|
my $needed = $max_page - $total_pages; |
|
73
|
7
|
50
|
|
|
|
31
|
die "negative number of needed pages, this is a bug" if $needed < 0; |
|
74
|
7
|
|
|
|
|
30
|
my @sequence = (1 .. $total_pages); |
|
75
|
7
|
100
|
|
|
|
29
|
if ($needed) { |
|
76
|
6
|
|
|
|
|
12
|
my $last; |
|
77
|
6
|
100
|
|
|
|
138
|
if ($self->cover) { |
|
78
|
5
|
|
|
|
|
53
|
$last = pop @sequence; |
|
79
|
|
|
|
|
|
|
} |
|
80
|
6
|
|
|
|
|
40
|
while ($needed > 0) { |
|
81
|
18
|
|
|
|
|
29
|
push @sequence, undef; |
|
82
|
18
|
|
|
|
|
39
|
$needed--; |
|
83
|
|
|
|
|
|
|
} |
|
84
|
6
|
100
|
|
|
|
24
|
push @sequence, $last if $last; |
|
85
|
|
|
|
|
|
|
} |
|
86
|
7
|
50
|
|
|
|
26
|
die "Something went off" if @sequence != $max_page; |
|
87
|
7
|
|
|
|
|
22
|
foreach my $pageno (@sequence) { |
|
88
|
68
|
|
|
|
|
20870
|
my $page = $self->out_pdf_obj->page; |
|
89
|
68
|
|
|
|
|
57506
|
my $gfx = $page->gfx; |
|
90
|
68
|
100
|
|
|
|
14351
|
if (my $chunk = $self->get_imported_page($pageno)) { |
|
91
|
50
|
|
|
|
|
2524850
|
$gfx->formimage($chunk, 0, 0); |
|
92
|
|
|
|
|
|
|
} |
|
93
|
|
|
|
|
|
|
} |
|
94
|
|
|
|
|
|
|
} |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head1 INTERNALS |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=head2 cropmarks_options |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
Disable signature. |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=cut |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
sub cropmarks_options { |
|
105
|
2
|
|
|
2
|
1
|
7
|
my $self = shift; |
|
106
|
2
|
|
|
|
|
21
|
my %options = ( |
|
107
|
|
|
|
|
|
|
top => 1, |
|
108
|
|
|
|
|
|
|
bottom => 1, |
|
109
|
|
|
|
|
|
|
inner => 1, |
|
110
|
|
|
|
|
|
|
outer => 1, |
|
111
|
|
|
|
|
|
|
# no shifting need |
|
112
|
|
|
|
|
|
|
twoside => 0, |
|
113
|
|
|
|
|
|
|
); |
|
114
|
2
|
50
|
33
|
|
|
42
|
if ($self->signature and $self->pages_per_sheet > 1) { |
|
115
|
0
|
|
|
|
|
0
|
$options{signature} = $self->computed_signature; |
|
116
|
|
|
|
|
|
|
} |
|
117
|
|
|
|
|
|
|
else { |
|
118
|
2
|
|
|
|
|
35
|
$options{signature} = 0; |
|
119
|
|
|
|
|
|
|
} |
|
120
|
|
|
|
|
|
|
|
|
121
|
2
|
|
|
|
|
36
|
return %options; |
|
122
|
|
|
|
|
|
|
} |
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
1; |