HTMLDOC_DATA
This environment variable specifies the location of htmldoc's data and fonts directories, normally /usr/share/htmldoc or C:/Program Files/HTMLDOC.
Convert html source files into html, postscript, or pdf.
htmldoc [options]
filename1.
html,md
[filenameN.
html,md]
htmldoc [options]
-
htmldoc [filename.book]
Htmldoc(1) converts HTML and Markdown source files into indexed HTML, PostScript, or Portable Document Format (PDF) files that can be viewed online or printed. With no options a HTML document is produced on stdout.
The second form of htmldoc reads HTML source from stdin, which allows you to use htmldoc as a filter.
The third form of htmldoc launches a graphical interface that allows you to change options and generate documents interactively.
There are two types of HTML files - structured documents using headings (H1, H2, etc.) which htmldoc calls "books", and unstructured documents that do not use headings which htmldoc calls "web pages".
A very common mistake is to try converting a web page using:
htmldoc -f filename.pdf filename.html
which will likely produce a PDF file with no pages. 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.
The following command-line options are supported by htmldoc:
--batch filename.bookGenerates the specified book file without opening the GUI.
--bodycolor colorSpecifies 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 filenameSpecifies the background image that is tiled on all pages.
--book
Specifies that the HTML sources are structured (headings, chapters, etc.)
--bottom marginSpecifies 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. Note: UTF-8 support is limited to the first 128 Unicode characters that are found in the input.
--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 directorySpecifies 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 sizeSpecifies the default font size for body text.
--fontspacing spacingSpecifies 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.
--footer fffSets the page footer to use on body pages. See the HEADERS/FOOTERS FORMATS section below.
--format format-t formatSpecifies 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).
--gray
Specifies that PostScript or PDF output should be grayscale.
--header fffSets the page header to use on body pages. See the HEADERS/FOOTERS FORMATS section below.
--header1 fffSets the page header to use on the first body/chapter page. See the HEADERS/FOOTERS FORMATS section below.
--headfootfont fontSets the font to use on headers and footers.
--headfootsize sizeSets the size of the font to use on headers and footers.
--headingfont typefaceSets the typeface to use for headings.
--help
Displays a summary of command-line options.
--helpdir directorySpecifies the location of the htmldoc online help files, usually /usr/share/doc/htmldoc or C:/Program Files/HTMLDOC/DOC.
--hfimageN filenameSpecifies 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 marginSpecifies the left margin in points (no suffix or ##pt), inches (##in), centimeters (##cm), or millimeters (##mm).
--letterhead filenameSpecifies 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.
--linkcolor colorSets the color of links.
--links
Enables generation of links in PDF files (default).
--linkstyle {plain,underline}Sets the style of links.
--logoimage filenameSpecifies 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.
--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 pagesSets the number of pages that are placed on each output page. Valid values are 1, 2, 4, 6, 9, and 16.
--outdir directory-d directorySpecifies that output should be sent to a directory in multiple files. (Not compatible with PDF output)
--outfile filename-f filenameSpecifies that output should be sent to a single file.
--owner-password passwordSets 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 effectSpecifies the page transition effect for all pages; this attribute is ignored by all Adobe PDF viewers.
--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 distanceSpecifies 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.
--referer urlSpecifies the URL that is passed in the Referer: field of HTTP requests.
--right marginSpecifies the right margin in points (no suffix or ##pt), inches (##in), centimeters (##cm), or millimeters (##mm).
--size pagesizeSpecifies 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.
--textcolor colorSpecifies the default color of all text.
--title
Enables the generation of a title page.
--titlefile filename--titleimage filenameSpecifies 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 fffSets the page footer to use on table-of-contents pages. See the HEADERS/FOOTERS FORMATS section below.
--tocheader fffSets the page header to use on table-of-contents pages. See the HEADERS/FOOTERS FORMATS section below.
--toclevels levelsSets the number of levels in the table-of-contents.
--toctitle stringSets the title for the table-of-contents.
--top marginSpecifies the top margin in points (no suffix or ##pt), inches (##in), centimeters (##cm), or millimeters (##mm).
--user-password passwordSpecifies the user password for encryption of PDF files.
--verbose
-v
Provides verbose messages.
--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.
Htmldoc returns a non-zero exit status if any errors are seen, zero otherwise.
Htmldoc exits with the number of errors that have occurred.
Htmldoc looks for several environment variables which can override the default directories, display additional debugging information, and disable CGI mode:
HTMLDOC_DATA
This environment variable specifies the location of htmldoc's data and fonts directories, normally /usr/share/htmldoc or C:/Program Files/HTMLDOC.
HTMLDOC_DEBUG
This environment variable enables debugging information that is sent to stderr. The value is a list of any of the following keywords separated by spaces: "all", "links", "memory", "remotebytes", "table", "tempfiles", and/or "timing".
HTMLDOC_HELP
This environment variable specifies the location of htmldoc's documentation directory, normally /usr/share/doc/htmldoc or C:/Program Files/HTMLDOC/doc.
HTMLDOC_NOCGI
This environment variable, when set (the value doesn't matter), disables CGI mode. It is most useful for using htmldoc on a web server from a scripting language or invocation from a program.
Create a PDF file from a web site:
htmldoc --webpage -f example.pdf http://www.example.com/
Create a PostScript book from a directory of HTML files
htmldoc --book -f example.pdf *.html
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.
14 releases since Debian 2.2 (Potato); the text changed 8 times.
--book since Debian 3.0 (Woody);
--color since Debian 3.0 (Woody);
--continuous since Debian 3.0 (Woody);
--duplex since Debian 3.0 (Woody);
--embedfonts since Debian 3.1 (Sarge);
--encryption since Debian 3.0 (Woody);
--gray since Debian 3.0 (Woody);
--help since Debian 3.0 (Woody);
--jpeg since Debian 3.0 (Woody);
--links since Debian 3.0 (Woody);
--no-compression since Debian 3.0 (Woody);
--no-duplex since Debian 3.0 (Woody);
--no-embedfonts since Debian 3.1 (Sarge);
--no-encryption since Debian 3.0 (Woody);
--no-jpeg since Debian 3.0 (Woody);
--no-links since Debian 3.0 (Woody);
--no-numbered since Debian 3.0 (Woody);
--no-pscommands since Debian 3.0 (Woody);
--no-strict since Debian 3.1 (Sarge);
--no-title since Debian 3.0 (Woody);
--no-toc since Debian 3.0 (Woody);
--numbered since Debian 3.0 (Woody);
--pscommands since Debian 3.0 (Woody);
--quiet since Debian 3.0 (Woody);
--strict since Debian 3.1 (Sarge);
--title since Debian 3.0 (Woody);
--verbose since Debian 3.0 (Woody);
--version since Debian 3.1 (Sarge);
--webpage since Debian 3.0 (Woody);
-v since Debian 3.0 (Woody).
--batch until Debian 9 (Stretch);
--bodycolor until Debian 9 (Stretch);
--bodyfont until Debian 9 (Stretch);
--bodyimage until Debian 9 (Stretch);
--bottom until Debian 9 (Stretch);
--charset until Debian 9 (Stretch);
--datadir until Debian 9 (Stretch);
--fontsize until Debian 9 (Stretch);
--fontspacing until Debian 9 (Stretch);
--footer until Debian 9 (Stretch);
--format until Debian 9 (Stretch);
--header until Debian 9 (Stretch);
--headfootfont until Debian 9 (Stretch);
--headfootsize until Debian 9 (Stretch);
--headingfont until Debian 9 (Stretch);
--helpdir until Debian 9 (Stretch);
--left until Debian 9 (Stretch);
--linkcolor until Debian 9 (Stretch);
--linkstyle until Debian 9 (Stretch);
--logoimage until Debian 9 (Stretch);
--no-truetype until Debian 3.0 (Woody);
--nup until Debian 9 (Stretch);
--outdir until Debian 9 (Stretch);
--outfile until Debian 9 (Stretch);
--owner-password until Debian 9 (Stretch);
--pageduration until Debian 9 (Stretch);
--pageeffect until Debian 9 (Stretch);
--pagelayout until Debian 9 (Stretch);
--pagemode until Debian 9 (Stretch);
--path until Debian 9 (Stretch);
--permissions until Debian 9 (Stretch);
--referer until Debian 9 (Stretch);
--right until Debian 9 (Stretch);
--size until Debian 9 (Stretch);
--textcolor until Debian 9 (Stretch);
--textfont until Debian 9 (Stretch);
--titlefile until Debian 9 (Stretch);
--titleimage until Debian 9 (Stretch);
--tocfooter until Debian 9 (Stretch);
--tocheader until Debian 9 (Stretch);
--toclevels until Debian 9 (Stretch);
--toctitle until Debian 9 (Stretch);
--top until Debian 9 (Stretch);
--truetype until Debian 3.0 (Woody);
--user-password until Debian 9 (Stretch);
-d until Debian 9 (Stretch);
-f until Debian 9 (Stretch);
-t until Debian 9 (Stretch).