| 1 | package PDF::Imposition::Schema2side; | ||||||||||
| 2 | 3 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | 3 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 3 | ▶ | use Moo; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 3 | 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<psnup -2> in the <psutils>. | ||||||||||
| 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 | 2 | ▶ | sub _do_impose { | ||||||||
|
Subroutine
_do_impose: called CC=4 SCAR=13.9
| |||||||||||
| 52 | 2 | my $self = shift; | |||||||||
| 53 | 2 | $self->out_pdf_obj->mediabox( | |||||||||
| 54 | $self->orig_width * 2, | ||||||||||
| 55 | $self->orig_height, | ||||||||||
| 56 | ); | ||||||||||
| 57 | 2 | my $total = $self->total_pages; | |||||||||
| 58 | 2 | my ($page, $gfx, $chunk); | |||||||||
| 59 | 2 | my @pages = (1..$total); | |||||||||
| 60 | 2 | ▶ | while (@pages) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 61 | 8 | $page = $self->out_pdf_obj->page; | |||||||||
| 62 | 8 | $gfx = $page->gfx; | |||||||||
| 63 | |||||||||||
| 64 | # first | ||||||||||
| 65 | 8 | $chunk = $self->get_imported_page(shift(@pages)); | |||||||||
| 66 | 8 | ▶ | $gfx->formimage($chunk, 0, 0) if $chunk; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 67 | |||||||||||
| 68 | # second | ||||||||||
| 69 | 8 | $chunk = $self->get_imported_page(shift(@pages)); | |||||||||
| 70 | 8 | ▶ | $gfx->formimage($chunk, $self->orig_width, 0) if $chunk; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 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 | 1 | ▶ | sub cropmarks_options { | ||||||||
|
Subroutine
cropmarks_options: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 88 | 1 | my %options = ( | |||||||||
| 89 | top => 1, | ||||||||||
| 90 | bottom => 1, | ||||||||||
| 91 | inner => 1, | ||||||||||
| 92 | outer => 0, | ||||||||||
| 93 | twoside => 1, | ||||||||||
| 94 | signature => 4, | ||||||||||
| 95 | ); | ||||||||||
| 96 | 1 | return %options; | |||||||||
| 97 | } | ||||||||||
| 98 | |||||||||||
| 99 | 1 | ▶ | sub pages_per_sheet { 4 }; | ||||||||
|
Subroutine
pages_per_sheet: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 100 | |||||||||||
| 101 | 3 | 1; | |||||||||
| 102 | |||||||||||
| 103 | =head1 SEE ALSO | ||||||||||
| 104 | |||||||||||
| 105 | L<PDF::Imposition> | ||||||||||
| 106 | |||||||||||
| 107 | =cut | ||||||||||
| 108 | |||||||||||
| 109 | |||||||||||