Is there a way to make "page" size match document length?
There was a solution given by Veytsman and Ware in Tugboat 32 (2011) 261 in an article titled "Ebooks and paper sizes: Output routines made easier" to be found at https://tug.org/TUGboat/tb32-3/tb102veytsman-ebooks.pdf
Their idea is not to make one big page for the whole document, but one page for each section, and they found a trick to set the page size dynamically to the actual size of the text without white space.
I worked out a preliminary version of a package using their idea. At
- http://users.phys.psu.edu/~collins/screenread/
- https://github.com/bishboria/screen-read-class
you can find the package, a test file and an example of the resulting pdf file. You could try modifying it to give one page for the whole of a document.
The result is subject to the maximum dimension of \maxdimen
of TeX.
\documentclass{article}
\setlength\textheight{30\textheight}
produces
! Dimension too large.
<recently read> \textheight
so simply making a very tall page causes problems for even quite modest documents.
TeX's architecture generally tries to clear out pages as quickly as possible, unlike line breaking which does a least cost analysis of the breaking over a whole paragraph, page breaking (usually) only considers one potential break at a time, and the memory taken up by the scroll for the page shipped out is recycled. This enabled TeX to process arbitrarily long documents even in the small memory available at the time.
Now of course, there is more memory available but it's not clear to see how TeX could adapt. Probably the thing to do would be to have a simplified output routine that continuously shipped out pages without adding header or footer at all; and then a simple post process with a pdf tool could stitch the pages back together.