# [NTG-pdftex] JBIG2 Stuff

Hartmut Henkel hartmut_henkel@gmx.de
Wed, 8 Jan 2003 19:33:41 +0100 (CET)

The flagging of required page0 segments is already done, the problem is
the later part, namely to flush them out. Who would trigger this?  It's
not up to the user, as he can until the very end decide to include yet
another image from a given JBIG2 file---which might also increase the
set of required page0 segments from that JBIG2 file.

The PDF spec gives one JBIG2Globals object, which may be referenced by
several images. To use this in a natural way means to make one
JBIG2Gobals object per JBIG2 file (or none, if not required). This
object must contain at least all page0 segments, which are referenced by
the selected subset of images from that JBIG2 file. If only a subset of
images is extracted from the JBIG2 file, there remain page0 segments,
which are not required for the decoding, and therefore do not need to be
included in the PDF file.

If one includes ALL page0 segments from a JBIG2 file rightaway, it won't
hurt, but several page0 segments are then unreferenced (as the
referencing images are missing), which is a (probably big) waste of PDF
file size.

Putting the burden of deciding when to flush page0 segments on the user
would mean, that he has to tell, which is the LAST real image included
from a given JBIG2 file. If he then flushes out the page0 segments of
that file, later inclusion of yet another image from the same file would
again require to create a fresh JBIG2Globals object, which is doubling
of information in the PDF file. And, if the user forgets to flush page0
stuff, the JBIG2 decoder of the reader will crash.

The way I try is to quietly mark required page0 segments as images are
included and wait to the very end (this +/- works), and then to flush
them out without user interaction, which fills one JBIG2Globals stream
per JBIG2 file.

Basically what I need is that, about at the time when the user says
\end, a call to a function e. g. flushallpages0() is done. The function
itself ist straight-forward.

Greetings Hartmut

On Wed, 8 Jan 2003, Hans Hagen wrote:

> i'm not sure if i understand the problem well, but can't you use call to
> \pdfrefximage to set flags?
>
> \pdfximage page 1 ... -> loads zero thing
> \pdfrefximage [this image obj number] -> sets flag on associated zero thing
>
> so, in the and you just flush the zero things that are flagged.
>
> Hans