use Text::PDF::File;
use Getopt::Std;


unless(defined $opt_n && defined $ARGV[1])
    die <<'EOT';
    pdfaddobj [-g gen] [-m num] -n num pdf_file data_file
Adds the given file as object number given by -n to pdf_file.

    -g gen      Generation number of -n to insert
    -m num      Font hack. Lookup object -m and add a reference
                to -n as FontFile2 in that dictionary
    -n num      Object number to insert/replace as

$f = Text::PDF::File->open($ARGV[0], 1) || "Can't open $ARGV[0]";
$res = $f->read_objnum($opt_n, $opt_g);

open(INFILE, $ARGV[1]) || die "Can't read $ARGV[1]";
$res->{' stream'} = "";
while (read(INFILE, $dat, 4096))
{ $res->{' stream'} .= $dat; }
delete $res->{' nofilt'};

if (defined $opt_m)
    $mres = $f->read_objnum($opt_m, 0);
    $mres->{'FontFile2'} = $res;