Pages 0, 2 and 3 are not rendered correctly
Pdf found at http://launchpadlibrarian.net/21544672/01004PT1.pdf
Created attachment 26981 [details] [review]
This patch appears to fix the bug.
The problem is that JBIG2Stream uses the Stream::getPos() of wrapped streams to determine segment length, specifically whether too many or too few characters have been read. A LOT of streams don't provide sane values and this trips up JBIG2Stream. (Notably ones that subclass FilterStream. FilterStream provides a default implementation of getPos() which is often wrong. It only works if the Filter does not blow up or shrink the data, i.e. there is one and only one call to str->readChar() for every call to readChar().)
The culprit in this case was DecryptStream.
Commited, keep up the good work :-)