App-PDF-Overlay

 view release on metacpan or  search on metacpan

README.md  view on Meta::CPAN

# 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

=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


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

# 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


################ 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

	    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

        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 1.462 second using v1.01-cache-2.11-cpan-49f99fa48dc )