prawnpdf/prawn — pull request #440 by cheba (2013-01-21 09:22:06+00:00)
Title: Maintain correct :Length entry value at all times

I've been working on something else when hit this. My tests were failing with "PDF malformed, missing stream length".

PDF Spec (at least v 1.4) states:

> Every stream dictionary has a **Length** entry that indicates how many bytes of the PDF file are used for the stream’s data.

I've discovered though that in Prawn :Length is only set for compressed streams. This is true not for all streams. Page ref as well as images and fonts get their :Length entries just right even when not compressed.

This patch fixes this injustice towards regular streams.