App-PDF-Overlay
view release on metacpan or search on metacpan
12345678910111213141516171819# 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
1213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970=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
8687888990919293949596979899100101102103104105106107108109110111112113114The 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
181920212223242526272829303132333435363738394041# 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
57585960616263646566676869707172737475767778################ 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::API2->new;
process(
$_
)
for
@ARGV
;
->saveas(
$output
);
warn
(
"Wrote: $output\n"
)
if
$verbose
;
script/pdfolay.pl view on Meta::CPAN
115116117118119120121122123124125126127128129130131132133134
delete
$i
{non_full_screen_page_mode};
->
$m
(
%i
);
}
}
for
(
my
$p
= 1;
$p
<=
$pages
;
$p
++ ) {
my
$page
=
->page;
->import_page(
$i_pdf
,
$p
,
$page
)
unless
$back
;
if
(
$overlay
&&
$o_pix
) {
$page
=
->import_page(
$o_pdf
,
$o_pix
,
$page
);
$o_pix
++;
if
(
$o_pix
>
$o_pdf
->page_count ) {
$o_pix
=
$repeat
? 1 : 0;
}
}
->import_page(
$i_pdf
,
$p
,
$page
)
if
$back
;
}
script/pdfolay.pl view on Meta::CPAN
148149150151152153154155156157158159160161162163164165166167168
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 )