Dynamically enlarge the height of a page [duplicate]

There is a way to dynamically enlarge a page in a LaTeX document? the thing I want is to have a document which will always have a single page, so the page should increase in height to hold all the document contents.

Of course it is possible :)

You can use the standalone class with the varwidth option to make the size automatically adjustable.

It can't get infinitely big (no computer can handle infinity) but this example code makes a 2.1 m wide and 5.6 m high page (in less than 7 seconds):

\documentclass[varwidth=500cm,margin=1cm]{standalone}
\usepackage{lipsum}
\begin{document}
\lipsum[1-150]
\lipsum[1-150]
\lipsum[1-150]
\lipsum[1-150]
\lipsum[1-150]
\lipsum[1-150]
\lipsum[1-150]
\lipsum[1-150]
\lipsum[1-150]
\end{document}


The argument you pass to varwidth is the width of the page, and its height grows dynamically.

If the page goes beyond 5.7 m tall TeX will complain, but long before that your PDF viewer will hang and you won't be able to read anything: