#!/usr/bin/perl -w use strict; # n21pdf.pl: A quick and dirty little program to convert multiple PDFs # to one PDF requires pdf2ps and Ghostscript # written by Faber Fedor (faber@linuxnj.com) 2003-05-27 # Tweaked by Ben Okopnik 05-27-2003 # Tweaked by John B. Silvestri 26 July 2003, to be a multiple PS -> PDF app die "Usage: ", $0 =~ /([^\/]+)$/, " \n" unless @ARGV == 2; my ( $PDFFILE, $PDFDIR ) = @ARGV; my $filelist; my ( $GS, $PDF2PS ) = ("/usr/bin/gs", "/usr/bin/pdftops"); my $GS_ARGS = " -dNOPAUSE -sDEVICE=pdfwrite -sPAPERSIZE=letter -sOUTPUTFILE=$PDFFILE -dBATCH "; print "Combining all .png files in $PDFDIR into $PDFFILE\n" ; #Convert all the PDFs to PS for ( <$PDFDIR/*pdf> ){ #s/png$//; print "temp: PNG2PS: ${_}\n"; system "$PDF2PS", "${_}" and die "$_ to $_.ps: PDF-PS conversion problem!\n"; #$filelist .= " $_"; } my @files=<$PDFDIR/*ps>; $filelist="@files"; my $cmd_string = $GS . $GS_ARGS . $filelist ; #convert ps files to a pdf file print "Running ps2pdf now...\n"; system $cmd_string and die "Problem combining files!\n"; # clean up after yourself print "Deleting temporary files (.ps)...\n"; unlink or die "$_: $!\n" for split ' ', $filelist; print "PDF successfully created.\n";