htmldoc(1)
๐ 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.) โhtmldoccalls these "books" ๐ - unstructured documents that do not use headings โ
htmldoccalls 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 thehtmldocdata files, usually/usr/share/htmldocorC:/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 of1.2will 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),psorps2(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),pdforpdf13(PDF 1.3/Acrobat 4.0), orpdf14(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 thehtmldoconline help files, usually/usr/share/doc/htmldocorC:/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 of0disables 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--footeroptions with theLparameter, or use the corresponding HTML page comments, to display the letterhead image in the header or footer. (capitalL, lowercaselis 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--footeroptions with thelparameter, or use the corresponding HTML page comments, to display the logo image in the header or footer. (lowercaselthis 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 PostScriptsetpagedevicecommands.--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 are1,2,4,6,9, and16.--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, andno-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 PostScriptsetpagedevicecommands 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 theReferer: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โฆ ๐
๐ HEADER/FOOTER FORMATS ๐
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 lettersAโ uppercase letterscโ current chapter headingCโ current chapter page number (arabic)dโ current dateDโ current date and timehโ current headingiโ lowercase roman numeralsIโ uppercase roman numeralslโ logo imageLโ logo image as letterhead โ the image is inserted at its maximum sizetโ title textTโ current timeuโ 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โ tellshtmldocwhere its data and fonts directories live. Normally that's/usr/share/htmldocorC:/Program Files/HTMLDOC.HTMLDOC_DEBUGโ turns on debugging info that gets sent tostderr๐ 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 ofhtmldoc's documentation directory, normally/usr/share/doc/htmldocorC:/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 runninghtmldocon 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 ๐
- HTMLDOC Users Manual
https://www.msweet.org/htmldoc
๐ฆ AUTHOR ๐ฆ
Michael R Sweet โ the actual main character ๐ซก
๐ LEGAL STUFF ๐
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 ๐โจ
๐ฆ where this page comes from
- alpine 3.24: htmldoc-doc 1.9.23-r0 ยท GPL-2.0-only
- arch rolling: htmldoc 1.9.25-1 ยท GPL-2.0-only
- nixos 26.05: htmldoc 1.9.23
- nixpkgs unstable: htmldoc 1.9.24
- opensuse-leap 16.0: htmldoc 1.9.23-bp160.1.1 ยท LGPL-2.1-or-later
- opensuse-leap 16.0: htmldoc 1.9.23-bp160.1.1 ยท LGPL-2.1-or-later
- opensuse-leap 16.0: htmldoc 1.9.23-bp160.1.1 ยท LGPL-2.1-or-later
- opensuse-leap 16.0: htmldoc 1.9.23-bp160.1.1 ยท LGPL-2.1-or-later
- ubuntu resolute: htmldoc-common 1.9.23-1 ยท GPL-2.0-only
- ubuntu stonking: htmldoc-common 1.9.23-1 ยท GPL-2.0-only
- Copyright 2011-2025 by Michael R Sweet
- Copyright 1997-2010 by msweet.org
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms