http://www.perlmonks.org?node_id=602742


in reply to Macintosh PDF's on Windows

Yes, you sure don't want to change the 0D into anything else... Apart from the xref table, there are typically also zipped (i.e. binary) streams, which also could contain 0D bytes.

As long as you open input and output filehandles without automatic line ending translation, you should be fine, though. And, if you need to process the file in a line-based fashion, just set the input record separator $/ to "\r" (=0D):

$/ = "\r"; open my $in_fh, "<:raw", "Mac_in.pdf" or die "$!"; open my $out_fh, ">:raw", "Mac_out.pdf" or die "$!"; while (<$in_fh>) { # do something with the line... print $out_fh $_; }

(also make sure to never change the size (number of bytes) of any objects in the PDF, or else the offsets given in the xref table will become incorrect... but you probably knew that already)