| 1 | package PDF::Imposition::Schema1x8x2; | ||||||||||
| 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::Schema1x8x2 - fixed 16 pages signatures on a single sheet, with triple folding. | ||||||||||
| 10 | |||||||||||
| 11 | =head1 SYNOPSIS | ||||||||||
| 12 | |||||||||||
| 13 | use PDF::Imposition::Schema1x8x2; | ||||||||||
| 14 | my $imposer = PDF::Imposition::Schema1x8x2->new( | ||||||||||
| 15 | file => "test.pdf", | ||||||||||
| 16 | output => "out.pdf", | ||||||||||
| 17 | ); | ||||||||||
| 18 | $imposer->impose; | ||||||||||
| 19 | |||||||||||
| 20 | The output pdf will be left in C<< $imposer->output >> | ||||||||||
| 21 | |||||||||||
| 22 | =head1 SCHEMA EXPLANATION | ||||||||||
| 23 | |||||||||||
| 24 | Fixed signature size of 16 pages, printed recto-verso on a single sheet. | ||||||||||
| 25 | |||||||||||
| 26 | Typical usage: print A6 on A3, then fold trice, first along the y | ||||||||||
| 27 | axys, then the x axys and finally the y axys again. You need to trim | ||||||||||
| 28 | the top and right margins before binding. | ||||||||||
| 29 | |||||||||||
| 30 | Not suitable for home-printing because the spine is unstable unless | ||||||||||
| 31 | done by a machine. | ||||||||||
| 32 | |||||||||||
| 33 | Visualization (the prefix C<r> means logical page disposed | ||||||||||
| 34 | upside-down -- rotated 180 degrees): | ||||||||||
| 35 | |||||||||||
| 36 | |||||||||||
| 37 | +------+------+------+------+ | ||||||||||
| 38 | | | | | | | ||||||||||
| 39 | | r5 | r12 | r9 | r8 | | ||||||||||
| 40 | | | | | | | ||||||||||
| 41 | +------+------+------+------+ | ||||||||||
| 42 | | | | | | | ||||||||||
| 43 | | 4 | 13 | 16 | 1 | | ||||||||||
| 44 | | | | | | | ||||||||||
| 45 | +------+------+------+------+ | ||||||||||
| 46 | |||||||||||
| 47 | +------+------+------+------+ | ||||||||||
| 48 | | | | | | | ||||||||||
| 49 | | r7 | r10 | r11 | r6 | | ||||||||||
| 50 | | | | | | | ||||||||||
| 51 | +------+------+------+------+ | ||||||||||
| 52 | | | | | | | ||||||||||
| 53 | | 2 | 15 | 14 | 3 | | ||||||||||
| 54 | | | | | | | ||||||||||
| 55 | +------+------+------+------+ | ||||||||||
| 56 | |||||||||||
| 57 | |||||||||||
| 58 | To complete the block of 16 logical pages, blank pages are inserted if | ||||||||||
| 59 | needed. | ||||||||||
| 60 | |||||||||||
| 61 | =cut | ||||||||||
| 62 | |||||||||||
| 63 | 2 | ▶ | sub _do_impose { | ||||||||
|
Subroutine
_do_impose: called CC=2 SCAR=6.9
| |||||||||||
| 64 | 2 | my $self = shift; | |||||||||
| 65 | # set the mediabox doubling them | ||||||||||
| 66 | 2 | $self->out_pdf_obj->mediabox( | |||||||||
| 67 | $self->orig_width * 4, | ||||||||||
| 68 | $self->orig_height * 2, | ||||||||||
| 69 | ); | ||||||||||
| 70 | # here we work with fixed signatures of 16, with the module | ||||||||||
| 71 | 2 | my $total = $self->total_pages; | |||||||||
| 72 | 2 | my @pages = (1..$total); | |||||||||
| 73 | |||||||||||
| 74 | # loop over the pages and compose the 4 physical pages | ||||||||||
| 75 | 2 | ▶ | while (@pages) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 76 | 3 | my ($p1, $p2, $p3, $p4, | |||||||||
| 77 | $p5, $p6, $p7, $p8, | ||||||||||
| 78 | $p9, $p10, $p11, $p12, | ||||||||||
| 79 | $p13, $p14, $p15, $p16) = splice @pages, 0, 16; | ||||||||||
| 80 | 3 | $self->_compose_eight($p4, $p13, $p16, $p1, | |||||||||
| 81 | $p8, $p9, $p12, $p5); | ||||||||||
| 82 | 3 | $self->_compose_eight($p2, $p15, $p14, $p3, | |||||||||
| 83 | $p6, $p11, $p10, $p7); | ||||||||||
| 84 | } | ||||||||||
| 85 | |||||||||||
| 86 | } | ||||||||||
| 87 | |||||||||||
| 88 | 6 | ▶ | sub _compose_eight { | ||||||||
|
Subroutine
_compose_eight: called CC=9 SCAR=22.8
| |||||||||||
| 89 | 6 | my ($self, @seq) = @_; | |||||||||
| 90 | 6 | my $chunk; | |||||||||
| 91 | 6 | my $page = $self->out_pdf_obj->page; | |||||||||
| 92 | 6 | my $gfx = $page->gfx; | |||||||||
| 93 | |||||||||||
| 94 | 6 | $chunk = $self->get_imported_page($seq[0]); | |||||||||
| 95 | 6 | ▶ | $gfx->formimage($chunk, 0, 0) if $chunk; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 96 | |||||||||||
| 97 | 6 | $chunk = $self->get_imported_page($seq[1]); | |||||||||
| 98 | 6 | ▶ | $gfx->formimage($chunk, $self->orig_width, 0) if $chunk; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 99 | |||||||||||
| 100 | 6 | $chunk = $self->get_imported_page($seq[2]); | |||||||||
| 101 | 6 | ▶ | $gfx->formimage($chunk, $self->orig_width * 2, 0) if $chunk; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 102 | |||||||||||
| 103 | 6 | $chunk = $self->get_imported_page($seq[3]); | |||||||||
| 104 | 6 | ▶ | $gfx->formimage($chunk, $self->orig_width * 3, 0) if $chunk; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 105 | |||||||||||
| 106 | # translate | ||||||||||
| 107 | 6 | $gfx->transform ( | |||||||||
| 108 | -translate => [$self->orig_width * 4, | ||||||||||
| 109 | $self->orig_height * 2], | ||||||||||
| 110 | -rotate => 180, | ||||||||||
| 111 | ); | ||||||||||
| 112 | |||||||||||
| 113 | 6 | $chunk = $self->get_imported_page($seq[4]); | |||||||||
| 114 | 6 | ▶ | $gfx->formimage($chunk, 0, 0) if $chunk; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 115 | |||||||||||
| 116 | 6 | $chunk = $self->get_imported_page($seq[5]); | |||||||||
| 117 | 6 | ▶ | $gfx->formimage($chunk, $self->orig_width, 0) if $chunk; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 118 | |||||||||||
| 119 | 6 | $chunk = $self->get_imported_page($seq[6]); | |||||||||
| 120 | 6 | ▶ | $gfx->formimage($chunk, $self->orig_width * 2, 0) if $chunk; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 121 | |||||||||||
| 122 | 6 | $chunk = $self->get_imported_page($seq[7]); | |||||||||
| 123 | 6 | ▶ | $gfx->formimage($chunk, $self->orig_width * 3, 0) if $chunk; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 124 | |||||||||||
| 125 | |||||||||||
| 126 | |||||||||||
| 127 | } | ||||||||||
| 128 | |||||||||||
| 129 | =head1 INTERNALS | ||||||||||
| 130 | |||||||||||
| 131 | =head2 pages_per_sheet | ||||||||||
| 132 | |||||||||||
| 133 | Returns 16 | ||||||||||
| 134 | |||||||||||
| 135 | =head2 cropmarks_options | ||||||||||
| 136 | |||||||||||
| 137 | Set inner to false and force signature to 16. | ||||||||||
| 138 | |||||||||||
| 139 | =cut | ||||||||||
| 140 | |||||||||||
| 141 | |||||||||||
| 142 | 1 | ▶ | sub pages_per_sheet { 16 } | ||||||||
|
Subroutine
pages_per_sheet: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 143 | |||||||||||
| 144 | 1 | ▶ | sub cropmarks_options { | ||||||||
|
Subroutine
cropmarks_options: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 145 | 1 | my %options = ( | |||||||||
| 146 | top => 1, | ||||||||||
| 147 | bottom => 1, | ||||||||||
| 148 | inner => 0, | ||||||||||
| 149 | outer => 1, | ||||||||||
| 150 | # no shifting need | ||||||||||
| 151 | twoside => 1, | ||||||||||
| 152 | signature => 16, | ||||||||||
| 153 | ); | ||||||||||
| 154 | 1 | return %options; | |||||||||
| 155 | } | ||||||||||
| 156 | |||||||||||
| 157 | |||||||||||
| 158 | |||||||||||
| 159 | |||||||||||
| 160 | 3 | 1; | |||||||||
| 161 | |||||||||||
| 162 | =head1 SEE ALSO | ||||||||||
| 163 | |||||||||||
| 164 | L<PDF::Imposition> | ||||||||||
| 165 | |||||||||||
| 166 | =cut | ||||||||||
| 167 | |||||||||||
| 168 | |||||||||||