[pdftex] Batch Page Extraction of PDFs

Anthony Wood woody+pdftex at switchonline.com.au
Thu Jun 5 10:56:51 CEST 2003

On Wed, Jun 04, 2003 at 09:09:36AM -0500, Michael T Metz wrote:
> Dear list:
> I'm looking for a way to extract the same page
> from many similar pdf files and put them in a
> single file. Has anyone done this or know a 
> possible avenue for me to investigate?

There are many ways to skin a cat :-)



Perl has a PDF::API2 module

here is a short program (merge.pl):

#! /usr/bin/perl -w

use strict;
use PDF::API2;

# last argument is the target PDF
my $merge = pop @ARGV;

# 1st argument is the page number
my $page = shift @ARGV

# other arguments are the source pdfs
my @pdfs = @ARGV;

# create new file
my $new = PDF::API2->new(-file => $merge);

# go through the source files
foreach my $spdf (map PDF::API2->open($_), at pdfs) {
  # add the page to the new file

# save the new file

so to get page 5 from all the pdfs in your directory and
put it into all5.pdf:

merge.pl 5 *.pdf all5.pdf

> Regards,
> Mike
> _______________________________________________
> pdftex mailing list
> pdftex at tug.org
> http://tug.org/mailman/listinfo/pdftex


More information about the pdftex mailing list