File Coverage

blib/lib/PDF/Imposition/Schema1repeat2side.pm
Criterion Covered Total %
statement 21 21 100.0
branch 2 4 50.0
condition n/a
subroutine 5 5 100.0
pod 1 1 100.0
total 29 31 93.5


line stmt bran cond sub pod time code
1             package PDF::Imposition::Schema1repeat2side;
2 3     3   1662 use strict;
  3         4  
  3         104  
3 3     3   11 use warnings;
  3         4  
  3         71  
4 3     3   8 use Moo;
  3         5  
  3         21  
5             with "PDF::Imposition::Schema";
6              
7             =head1 NAME
8              
9             PDF::Imposition::Schema1repeat2side - put two identical pages side by side on the same physical sheet
10              
11             =head1 SYNOPSIS
12              
13             use PDF::Imposition::Schema1repeat2side;
14             my $imposer = PDF::Imposition::Schema1repeat2side->new(
15             file => "test.pdf",
16             output => "out.pdf",
17             );
18             $imposer->impose;
19              
20             =head1 SCHEMA EXPLANATION
21              
22             +-----+-----+ +-----+-----+
23             | | | | | |
24             | 1 | 1 | | 2 | 2 |
25             | | | | | |
26             +-----+-----+ +-----+-----+
27              
28             The same logical page is inserted twice, side by side, on the same
29             sheet, nothing else. Typical usage scenario: printing A5 leaflets on
30             A4, then cut the sheets vertically.
31              
32             =cut
33              
34              
35             sub _do_impose {
36 2     2   6 my $self = shift;
37 2         31 $self->out_pdf_obj->mediabox(
38             $self->orig_width * 2,
39             $self->orig_height,
40             );
41 2         249 foreach my $pageno (1..$self->total_pages) {
42 6         848 my ($page, $gfx, $chunk);
43 6         104 $page = $self->out_pdf_obj->page;
44 6         1749 $gfx = $page->gfx;
45 6         669 $chunk = $self->get_imported_page($pageno);
46 6 50       527300 $gfx->formimage($chunk, 0, 0) if $chunk;
47 6         1477 $chunk = $self->get_imported_page($pageno);
48 6 50       5298 $gfx->formimage($chunk, $self->orig_width, 0) if $chunk;
49             }
50             }
51              
52             =head1 INTERNALS
53              
54             =head2 cropmarks_options
55              
56             Set twoside to false.
57              
58             =cut
59              
60             sub cropmarks_options {
61 1     1 1 19 my %options = (
62             top => 1,
63             bottom => 1,
64             inner => 1,
65             outer => 1,
66             # no shifting need
67             twoside => 0,
68             signature => 0,
69             );
70 1         12 return %options;
71             }
72              
73             1;