--- a/lib/PDF/API2/Basic/PDF/File.pm 2017-01-26 10:30:03.000000000 -0800 +++ b/lib/PDF/API2/Basic/PDF/File.pm 2017-06-21 16:33:17.000000000 -0700 @@ -1273,7 +1273,7 @@ my $tloc = $fh->tell(); $fh->print("xref\n"); - my @xreflist = sort { $self->{' objects'}{$a->uid}[0] <=> $self->{' objects'}{$b->uid}[0] } (@{$self->{' printed'}}, @{$self->{' free'}}); + my @xreflist = sort { $self->{' objects'}{$a->uid}[0] <=> $self->{' objects'}{$b->uid}[0] } (@{$self->{' printed'}||[]}, @{$self->{' free'}||[]}); my ($i, $j, $k); unless ($update) { @@ -1294,7 +1294,7 @@ } } - my @freelist = sort { $self->{' objects'}{$a->uid}[0] <=> $self->{' objects'}{$b->uid}[0] } @{$self->{' free'}}; + my @freelist = sort { $self->{' objects'}{$a->uid}[0] <=> $self->{' objects'}{$b->uid}[0] } @{$self->{' free'}||[]}; $j = 0; my $first = -1; $k = 0; for ($i = 0; $i <= $#xreflist + 1; $i++) {