htmldoc(1)

๐Ÿ“ฆ
version 1.9.25 ยท 4 versions
, in alpine 3.24, arch rolling, nixos 26.05, nixpkgs unstable, opensuse-leap 16.0, ubuntu resolute, ubuntu stonking

๐Ÿ’– htmldoc ๐Ÿ’–

okay bestie, gather round, because this is the manual page for htmldoc (that's htmldoc(1) if you're being fancy, written by Michael R Sweet) and it is lowkey a whole personality. it converts your HTML into pretty much whatever you want. no cap. ๐Ÿฆ‹


โœจ NAME โœจ

htmldoc โ€” convert html source files into html, postscript, or pdf.


๐ŸŒธ SYNOPSIS ๐ŸŒธ

htmldoc [options] filename1.{html,md} [ ... filenameN.{html,md} ]

htmldoc [options] -

htmldoc [filename.book]

๐ŸŽ€ DESCRIPTION ๐ŸŽ€

Htmldoc(1) takes your HTML and Markdown source files and turns them into indexed HTML, PostScript, or Portable Document Format (PDF) files โ€” the kind you can either vibe with online or print out and hold in your hands like it's 2004. and here's the thing: if you give it no options at all, it just produces an HTML document straight onto stdout. no drama, no fuss. ๐Ÿ’…

The second form of htmldoc reads HTML source from stdin, which is the whole reason you can use htmldoc as a filter. pipe it, bestie. ๐Ÿซถ

The third form of htmldoc launches a graphical interface, so you can click around, change options, and generate documents interactively like the main character you are. ๐Ÿ‘‘


๐Ÿ˜ญ COMMON MISTAKES ๐Ÿ˜ญ

so there are two types of HTML files and honestly this trips everyone up:

  • structured documents that use headings (H1, H2, etc.) โ€” htmldoc calls these "books" ๐Ÿ“š
  • unstructured documents that do not use headings โ€” htmldoc calls these "web pages" ๐ŸŒ

A very common mistake is trying to convert a web page using:

htmldoc -f filename.pdf filename.html

which will likely produce a PDF file with no pages. ๐Ÿ’€ not me doing this the first time. To convert web page files you must use the --webpage or --continuous options at the command-line, or choose Web Page or Continuous in the input tab of the GUI. periodt.


๐Ÿ’… OPTIONS ๐Ÿ’…

The following command-line options are supported by htmldoc:

  • --batch filename.book โ€” generates the specified book file without opening the GUI. set it and forget it, no windows popping up on you. โœจ
  • --bodycolor color โ€” specifies the background color for all pages.
  • --bodyfont {courier,helvetica,monospace,sans,serif,times}
  • --textfont {courier,helvetica,monospace,sans,serif,times} โ€” specifies the default typeface for all normal text.
  • --bodyimage filename โ€” specifies the background image that is tiled on all pages. tiled, as in repeated everywhere. wallpaper energy. ๐Ÿ–ผ๏ธ
  • --book โ€” specifies that the HTML sources are structured (headings, chapters, etc.)
  • --bottom margin โ€” specifies the bottom margin in points (no suffix or ##pt), inches (##in), centimeters (##cm), or millimeters (##mm).
  • --charset {cp-nnnn,iso-8859-1,...,iso-8859-15,utf-8} โ€” specifies the character set to use for the output. > heads up: UTF-8 support is limited to the first 128 Unicode characters that are found in the input. so like, keep it simple bestie. ๐Ÿ™ˆ
  • --color โ€” specifies that PostScript or PDF output should be in color. ๐ŸŒˆ
  • --continuous โ€” specifies that the HTML sources are unstructured (plain web pages.) No page breaks are inserted between each file or URL in the output.
  • --datadir directory โ€” specifies the location of the htmldoc data files, usually /usr/share/htmldoc or C:/Program Files/HTMLDOC.
  • --duplex โ€” specifies that the output should be formatted for double-sided printing.
  • --effectduration {0.1...10.0} โ€” specifies the duration in seconds of PDF page transition effects.
  • --embedfonts โ€” specifies that fonts should be embedded in PDF and PostScript output.
  • --encryption โ€” enables encryption of PDF files. ๐Ÿ”’
  • --fontsize size โ€” specifies the default font size for body text.
  • --fontspacing spacing โ€” specifies the default line spacing for body text. The line spacing is a multiplier for the font size, so a value of 1.2 will provide an additional 20% of space between the lines. math queen. ๐Ÿงฎ
  • --footer fff โ€” sets the page footer to use on body pages. See the HEADERS/FOOTERS FORMATS section below.
  • --format format
  • -t format โ€” specifies the output format: epub, html, htmlsep (separate HTML files for each heading in the table-of-contents), ps or ps2 (PostScript Level 2), ps1 (PostScript Level 1), ps3 (PostScript Level 3), pdf11 (PDF 1.1/Acrobat 2.0), pdf12 (PDF 1.2/Acrobat 3.0), pdf or pdf13 (PDF 1.3/Acrobat 4.0), or pdf14 (PDF 1.4/Acrobat 5.0). so many flavors, pick your fighter. ๐ŸฅŠ
  • --gray โ€” specifies that PostScript or PDF output should be grayscale.
  • --header fff โ€” sets the page header to use on body pages. See the HEADERS/FOOTERS FORMATS section below.
  • --header1 fff โ€” sets the page header to use on the first body/chapter page. See the HEADERS/FOOTERS FORMATS section below.
  • --headfootfont font โ€” sets the font to use on headers and footers.
  • --headfootsize size โ€” sets the size of the font to use on headers and footers.
  • --headingfont typeface โ€” sets the typeface to use for headings.
  • --help โ€” displays a summary of command-line options. your bestie when you're lost. ๐Ÿซถ
  • --helpdir directory โ€” specifies the location of the htmldoc online help files, usually /usr/share/doc/htmldoc or C:/Program Files/HTMLDOC/DOC.
  • --hfimageN filename โ€” specifies an image (numbered from 1 to 10) to be used in the header or footer in a PostScript or PDF document.
  • --jpeg[=quality] โ€” sets the JPEG compression level to use for large images. A value of 0 disables JPEG compression.
  • --left margin โ€” specifies the left margin in points (no suffix or ##pt), inches (##in), centimeters (##cm), or millimeters (##mm).
  • --letterhead filename โ€” specifies an image to be used as a letterhead in the header or footer in a PostScript or PDF document. > note that you need to use the --header, --header1, and/or --footer options with the L parameter, or use the corresponding HTML page comments, to display the letterhead image in the header or footer. (capital L, lowercase l is a different thing entirely, keep reading ๐Ÿ‘€)
  • --linkcolor color โ€” sets the color of links.
  • --links โ€” enables generation of links in PDF files (default).
  • --linkstyle {plain,underline} โ€” sets the style of links.
  • --logoimage filename โ€” specifies an image to be used as a logo in the header or footer in a PostScript or PDF document, and in the navigation bar of a HTML document. > note that you need to use the --header, --header1, and/or --footer options with the l parameter, or use the corresponding HTML page comments, to display the logo image in the header or footer. (lowercase l this time, bestie โ€” it's giving very "case-sensitive" ๐Ÿ’€)
  • --no-compression โ€” disables compression of PostScript or PDF files.
  • --no-duplex โ€” disables double-sided printing.
  • --no-embedfonts โ€” specifies that fonts should not be embedded in PDF and PostScript output.
  • --no-encryption โ€” disables document encryption.
  • --no-jpeg โ€” disables JPEG compression of large images.
  • --no-links โ€” disables generation of links in a PDF document.
  • --no-numbered โ€” disables automatic heading numbering.
  • --no-pscommands โ€” disables generation of PostScript setpagedevice commands.
  • --no-strict โ€” disables strict HTML input checking.
  • --no-title โ€” disables generation of a title page.
  • --no-toc โ€” disables generation of a table of contents.
  • --numbered โ€” numbers all headings in a document.
  • --nup pages โ€” sets the number of pages that are placed on each output page. Valid values are 1, 2, 4, 6, 9, and 16.
  • --outdir directory
  • -d directory โ€” specifies that output should be sent to a directory in multiple files. (Not compatible with PDF output) ๐Ÿšซ
  • --outfile filename
  • -f filename โ€” specifies that output should be sent to a single file.
  • --owner-password password โ€” sets the owner password for encrypted PDF files.
  • --pageduration I{1.0...60.0} โ€” sets the view duration of a page in a PDF document.
  • --pageeffect effect โ€” specifies the page transition effect for all pages; > this attribute is ignored by all Adobe PDF viewers. so cute, so pointless. ๐Ÿ’€
  • --pagelayout {single,one,twoleft,tworight} โ€” specifies the initial layout of pages for a PDF file.
  • --pagemode {document,outlines,fullscreen} โ€” specifies the initial viewing mode for a PDF file.
  • --path โ€” specifies a search path for files in a document.
  • --permissions permission[,permission,...] โ€” specifies document permissions for encrypted PDF files. The following permissions are understood: all, none, annotate, no-annotate, copy, no-copy, modify, no-modify, print, and no-print. Separate multiple permissions with commas.
  • --pre-indent distance โ€” specifies the indentation of pre-formatted text in points (no suffix or ##pt), inches (##in), centimeters (##cm), or millimeters (##mm).
  • --pscommands โ€” specifies that PostScript setpagedevice commands should be included in the output.
  • --quiet โ€” suppresses all messages, even error messages. ๐Ÿคซ silence is golden.
  • --referer url โ€” specifies the URL that is passed in the Referer: field of HTTP requests.
  • --right margin โ€” specifies the right margin in points (no suffix or ##pt), inches (##in), centimeters (##cm), or millimeters (##mm).
  • --size pagesize โ€” specifies the page size using a standard name or in points (no suffix or ##x##pt), inches (##x##in), centimeters (##x##cm), or millimeters (##x##mm). The standard sizes that are currently recognized are "letter" (8.5x11in), "legal" (8.5x14in), "a4" (210x297mm), and "universal" (8.27x11in). ๐Ÿ“„
  • --strict โ€” enables strict HTML input checking. no sloppy markup on your watch.
  • --textcolor color โ€” specifies the default color of all text.
  • --title โ€” enables the generation of a title page.
  • --titlefile filename
  • --titleimage filename โ€” specifies the file to use for the title page. If the file is an image then the title page is automatically generated using the document meta data and title image. โœจ
  • --tocfooter fff โ€” sets the page footer to use on table-of-contents pages. See the HEADERS/FOOTERS FORMATS section below.
  • --tocheader fff โ€” sets the page header to use on table-of-contents pages. See the HEADERS/FOOTERS FORMATS section below.
  • --toclevels levels โ€” sets the number of levels in the table-of-contents.
  • --toctitle string โ€” sets the title for the table-of-contents.
  • --top margin โ€” specifies the top margin in points (no suffix or ##pt), inches (##in), centimeters (##cm), or millimeters (##mm).
  • --user-password password โ€” specifies the user password for encryption of PDF files.
  • --verbose
  • -v โ€” provides verbose messages. it will not stop talking. ๐Ÿ—ฃ๏ธ
  • --version โ€” displays the current version number.
  • --webpage โ€” specifies that the HTML sources are unstructured (plain web pages.) A page break is inserted between each file or URL in the output.

๐Ÿ‘‘ EXIT STATUS ๐Ÿ‘‘

Htmldoc returns a non-zero exit status if any errors are seen, zero otherwise. simple as. โœจ


okay that's the first half, bestie โ€” the rest is loadingโ€ฆ ๐Ÿ’–

okay so this is the glow-up part, bestie โ€” you get to be the art director of your own document ๐Ÿ’… The header and the footer of each page can each hold up to three preformatted values. You pick them with a single character for the left, the middle, and the right of the page โ€” that's the fff notation we were talking about earlier (iykyk).

Every one of those characters can be one of these, no cap:

  • . โ€” blank ๐Ÿซฅ (yes bestie, just nothing)
  • / โ€” n/N arabic page numbers (1/3, 2/3, 3/3)
  • : โ€” c/C arabic chapter page numbers (1/2, 2/2, 1/4, 2/4, ...)
  • 1 โ€” arabic numbers (1, 2, 3, ...)
  • a โ€” lowercase letters
  • A โ€” uppercase letters
  • c โ€” current chapter heading
  • C โ€” current chapter page number (arabic)
  • d โ€” current date
  • D โ€” current date and time
  • h โ€” current heading
  • i โ€” lowercase roman numerals
  • I โ€” uppercase roman numerals
  • l โ€” logo image
  • L โ€” logo image as letterhead โ€” the image is inserted at its maximum size
  • t โ€” title text
  • T โ€” current time
  • u โ€” current filename or URL

๐Ÿ’€ EXIT STATUS ๐Ÿ’€

htmldoc exits with the number of errors that have occurred. That's it, that's the whole vibe check โ€” zero errors, zero drama ๐Ÿซถ


๐ŸŒˆ ENVIRONMENT ๐ŸŒˆ

htmldoc goes looking for a few environment variables, and those bad boys can override the default directories, spill extra debugging tea, and even disable CGI mode. Iconic behaviour, honestly:

  • HTMLDOC_DATA โ€” tells htmldoc where its data and fonts directories live. Normally that's /usr/share/htmldoc or C:/Program Files/HTMLDOC.
  • HTMLDOC_DEBUG โ€” turns on debugging info that gets sent to stderr ๐Ÿ‘€ The value is a list of any of these keywords, separated by spaces: "all", "links", "memory", "remotebytes", "table", "tempfiles", and/or "timing".
  • HTMLDOC_HELP โ€” points at the location of htmldoc's documentation directory, normally /usr/share/doc/htmldoc or C:/Program Files/HTMLDOC/doc.
  • HTMLDOC_NOCGI โ€” when this one is set (the value doesn't matter, bestie, literally any value), it disables CGI mode. It's most useful when you're running htmldoc on a web server from a scripting language, or calling it from inside another program.

โœจ EXAMPLES โœจ

Wanna make a PDF out of a whole website? Say less:

htmldoc --webpage -f example.pdf http://www.example.com/

Wanna make a PostScript book out of a directory full of HTML files? Periodt:

htmldoc --book -f example.pdf *.html

๐Ÿ‘‘ SEE ALSO ๐Ÿ‘‘


๐Ÿฆ‹ AUTHOR ๐Ÿฆ‹

Michael R Sweet โ€” the actual main character ๐Ÿซก


HTMLDOC is copyright ยฉ 1997-2025 by Michael R Sweet.

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.


and that's the whole page, bestie ๐Ÿ’œ this one's from HTMLDOC 1.9.22, dated 2025-12-23, and it lives in section htmldoc(1) โ€” go forth and make gorgeous PDFs, you absolute icon ๐ŸŽ€โœจ