HTMLDOC is a previously commercially developed open-source program that converts HTML and Markdown web pages and files to EPUB, indexed HTML, PostScript, and PDF files, complete with a table of contents.
HTMLDOC can be used from the command line, a simple GUI, or from a web server.
HTMLDOC 1.9 uses several proprietary processing instructions for formatting the pdf output, these use the syntax of the HTML comments.
It is legal to compile the sources and distribute the program, and various versions can be found on the Internet.
For example, HTMLDOC is included as part of the Debian operating systems.