[pdftex] Re: redirecting tex dvi output

Klaus Guntermann guntermann at iti.informatik.tu-darmstadt.de
Tue Jan 15 09:19:11 CET 2002


I would like to comment this.

Robin Fairbairns wrote:
 > tex does it because it predates the "intuition" that there's always
 > enough memory to hold the entirety of a file.  tex needs to patch
 > links through the dvi file and the like; it probably could be recoded
 > to avoid that nowadays.

Because TeX, the program, was originally written in Pascal, it simply
could not move to random positions in the DVI file. Therefore the
format of DVI files was carefully designed to allow creating the file
in one sweep. All links in the DVI file are going backward to already
known positions, namely the start of the previous page. In the
postamble of the file a link points to the last page.
See the remark by David Fuchs on this in TUGboat, Vol. 1, No. 1 (1980), 
page 19. 
The problem, that a pipe with TeX followed by a preview program or
other DVI converter does not work, is not introduced by TeX, but by
the reading program. These programs usually want to see the postamble
from the end of the DVI file first. 

Heiko Oberdiek wrote: 
> pdfTeX does not write the PDF file byte after byte,
> sometimes it goes back and changes some bytes
> (length of streams).

This again is not required by the pdf file format (and has not been
done by all pdftex versions before). The length of a stream can be
represented by an indirect object. The value can be given after the
stream is written. Of course the indirect version is less compact.
On the other hand one does not even know in advance the number of
digits needed for the length. In a version I checked pdftex seems to
reserve the maximum number of spaces for the digits to represent the
length of each stream to be able to insert any length later. This is
somewhat more compact than the indirect length at the cost of needing
the random positioning. 
If one would want to avoid random positioning during creation of a pdf
file, it could help to prepare the stream using an indirect length
first and try to keep the stream in a reasonably sized buffer. If the
buffer was sufficiently large, replace the indirect length by the
actually needed value and write it. Otherwise supply the indirect
length afterwards. Compared to a stream not fitting into the buffer
the space overhead of the indirect length seems acceptable. For small
streams the length could be supplied directly not even wasting
spaces.

Klaus Guntermann
-- 
	Klaus Guntermann	<guntermann at iti.informatik.tu-darmstadt.de>
	FG Systemprogrammierung, FB Informatik, TU Darmstadt
	Wilhelminenstr. 7, 64283 Darmstadt, Germany



More information about the pdftex mailing list