print scalar <>; while (!eof(ARGV)) { $pos = tell(ARGV); $line = scalar <>; my ($Obj) = $line =~ /^(\d+) \d+ obj/; $xref[$Obj - 1] = $pos if defined $Obj; $Str{$#xref + 1}->[0] = tell(ARGV) if $line =~ /^stream/; $Str{$#xref + 1}->[1] = $pos if $line =~ /^endstream/; print $line; } $pos = tell; print "xref\n0 ", scalar @xref + 1, "\n"; printf "%010d 65535 f \n", 0; foreach $entry (@xref) { printf "%010d 00000 n \n", $entry; } print "trailer\n<< /Size ", scalar @xref + 1, " /Root 1 0 R /Info 8 0 R >>\n"; print "startxref\n$pos\n%%EOF\n"; for my $Key (sort {$a <=> $b} keys %Str){ warn "Stream in $Key ", "begins: $Str{$Key}->[0] ", "ends: $Str{$Key}->[1] ", "length: @{[$Str{$Key}->[1] - $Str{$Key}->[0]]}\n"; }