{Ebooks and paper size: Output routine hacking made~easy} {Boris Veytsman and Michael Ware} {It might be surprising for a casual \TeX{} user, but the classical \TeX{} engine does not know anything about the physical dimensions of the paper the text is printed upon. One may argue that it imitates the traditional compositor, who prepared the matrix, but was not involved in the actual printing. Another explanation would be that a printer (a device, not a person) usually has a stock of pre-cut paper sheets, and there is not much use in trying change the paper size from the typesetting program. While both dvips and pdf\TeX{} provide the possibility to set the paper dimensions using either PostScript or \PDF\ commands embedded in the text, it is commonly done only once per document. This practice assumes uniform paper size for all pages. The situation with ebooks is different. ``Paper'' for them is virtual, and we are not constrained by the constant page size of traditional books. On the other hand, typesetting for the screen \emph{requires} paper size tuning. Since the page size is determined during \CS{shipout}, we need to deal with the output routine\Dash the task often considered to be too arcane for unexperienced \TeX nicians. In this talk we show that playing with the output routines does not necessarily involve high wizardry. We show how to use the output routine to determine the required paper size and to communicate it to the driver. The talk is intended for a beginning to intermediate \TeX{} hacker. }