johnwhitington / camlpdf

OCaml library for reading, writing and modifying PDF files
Other
200 stars 28 forks source link

Pdfops does not recompress inline images. #53

Closed johnwhitington closed 1 year ago

johnwhitington commented 1 year ago

This is not a problem normally, because the whole stream will be compressed.

However, if we read a malformed file which has too much image data, for example Flate encoded, it works. Then we write the file, with the inline image not compressed. Now, the end of the data is hard to find, and the fallback EI check must be used.

Better to write the inline image with a compression mechanism which allows the end of the data to be determined more easily, for example AHx.

johnwhitington commented 1 year ago

We now compress with FlateDecode if no compression is present. We also write the /L length argument (new in PDF 2.0).