17

Another approach, usable with LuaLaTeX. The following sample document was made with the files below.
The TeX input file
\documentclass{article}
\directlua{ require("drawboxes")}
\usepackage{graphicx,atbegshi}
\AtBeginShipout {\directlua{drawboxes.visual_debug()}}
\begin{document}
\hsize 3in
...