App-PDF-Overlay

 view release on metacpan or  search on metacpan

README.md  view on Meta::CPAN

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# pdfolay - insert a PDF document over/under another document
 
A.k.a. `App::PDF::Overlay`
 
This program will read the given input PDF file(s) and copy them
into a new output document.
 
Optionally, an overlay PDF document can be specified. If so, the pages
of the overlay document are inserted over (or, with option
--behind, behind) the pages of the source documents.
 
## Installation
 
To install this module, run the following commands:
 
        perl Makefile.PL
        make
        make test
        make install

lib/App/PDF/Overlay.pm  view on Meta::CPAN

12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
=cut
 
our $VERSION = '0.002';
 
=head1 SYNOPSIS
 
pdfolay [options] [file ...]
 
 Options:
   --output=XXX         output document (default "__new__.pdf")
   --overlay=XXX        name of the overlay PDF document
   --back               overlay behind the source document
   --behind             same as --back
   --restart            restart the overlay at every source
   --repeat             cycle overlay pages if source hase more pages
   --ident              shows identification
   --help               shows a brief help message and exits
   --man                shows full documentation and exits
   --verbose            provides more verbose information
   --quiet              runs as silently as possible
 
=head1 OPTIONS
 
=over 8
 
=item B<--output=>I<XXX>
 
Name of the resultant PDF document.
 
Default is C<__new__.pdf>.
 
=item B<--overlay=>I<XXX>
 
Name of the PDF document to overlay.
 
=item B<--back>
 
Insert the overlay document I<behind> the source documents.
 
=item B<--repeat>
 
Repeat (cycle through) the pages of the overlay document when the
source document has more pages than the overlay.
 
Default is to stop overlaying when the pages of the overlay document
are exhausted.
 
=item B<--restart>
 
Restart overlaying with the first page of the overlay document when a
new source document is processed.
 
=item B<--help>
 
Prints a brief help message and exits.
 
=item B<--man>
 
Prints the manual page and exits.

lib/App/PDF/Overlay.pm  view on Meta::CPAN

86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
The input PDF documents.
 
=back
 
=head1 DESCRIPTION
 
B<This program> will read the given input PDF file(s) and copy them
into a new output document.
 
Optionally, an overlay PDF document can be specified. If so, the pages
of the overlay document are inserted over (or, with option
B<--behind>, behind) the pages of the source documents.
 
When the source documents have more pages than the overlay document,
there are a couple of ways to reuse the overlay pages. These can be
controlled with the options B<--restart> and B<--repeat>.
 
Assuming the source documents have pages A B C and D E F, and the
overlay document has pages X Y, then the combinations are:
 
    default:        AX BY C   D  E  F
    repeat:         AX BY CX  DY EX FY
    restart:        AX BY C   DX EY F
    repeat+restart: AX BY CX  DX EY FX
 
=head1 AUTHOR
 
Johan Vromans, C<< <JV at cpan.org> >>

script/pdfolay.pl  view on Meta::CPAN

18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# Package name.
my $my_package = 'Sciurix';
# Program name and version.
my ($my_name, $my_version) = ( 'pdfolay', $App::PDF::Overlay::VERSION );
 
################ Command line parameters ################
 
use Getopt::Long 2.13;
 
# Command line options.
my $overlay;                    # the overlay file
my $back;                       # insert behind
my $restart;                    # restart overlay at a new source file
my $repeat;                     # repeat overlay pages
my $output;                     # the new output document
my $verbose = 1;                # verbose processing
 
# Development options (not shown with -help).
my $debug = 0;                  # debugging
my $trace = 0;                  # trace (show process)
my $test = 0;                   # test mode.
 
# Process command line options.
app_options();

script/pdfolay.pl  view on Meta::CPAN

57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
################ Presets ################
 
my $TMPDIR = $ENV{TMPDIR} || $ENV{TEMP} || '/usr/tmp';
 
################ The Process ################
 
use PDF::API2 2.042;
 
my $o_pdf;
if ( $overlay ) {
    $o_pdf = PDF::API2->open($overlay)
      or die("$overlay: $!\n");
}
my $o_pix = 1;                  # page index
 
my $pdf = PDF::API2->new;
 
process($_) for @ARGV;
 
$pdf->saveas($output);
warn("Wrote: $output\n") if $verbose;

script/pdfolay.pl  view on Meta::CPAN

115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
        delete $i{non_full_screen_page_mode};
        $pdf->$m(%i);
    }
}
 
for ( my $p = 1; $p <= $pages; $p++ ) {
    my $page = $pdf->page;
 
    $pdf->import_page( $i_pdf, $p, $page ) unless $back;
 
    if ( $overlay && $o_pix ) {
        $page = $pdf->import_page( $o_pdf, $o_pix, $page );
        $o_pix++;
        if ( $o_pix > $o_pdf->page_count ) {
            $o_pix = $repeat ? 1 : 0;
        }
    }
 
    $pdf->import_page( $i_pdf, $p, $page ) if $back;
}

script/pdfolay.pl  view on Meta::CPAN

148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
    require Pod::Usage;
    require Pod::Find;
    Pod::Usage->import;
    my $f = Pod::Find::pod_where( { -inc => 1}, "App::PDF::Overlay" );
    &pod2usage( -input => $f );
    &pod2usage;
};
 
# Process options.
if ( @ARGV > 0 ) {
    GetOptions( 'overlay=s' => \$overlay,
                'back|behind' => \$back,
                'output=s'  => \$output,
                'restart'   => \$restart,
                'repeat'    => \$repeat,
                'ident'     => \$ident,
                'version'   => \$version,
                'verbose+'  => \$verbose,
                'quiet'     => sub { $verbose = 0 },
                'trace'     => \$trace,
                'help|?'    => \$help,



( run in 0.267 second using v1.01-cache-2.11-cpan-26ccb49234f )