45
The CGI converts a page on your local server to PDF and sends it to the client's web browser. For example, to
convert a page called superproducts.html at the following URL:
http://servername/superproducts.html
and if you installed HTMLDOC in your server's cgi-bin directory, you would direct your clients to the
following URL:
http://servername/cgi-bin/htmldoc/superproducts.html
The boldface portion represents the location of the HTMLDOC executable on the web server. You simply
place that path before the page you want to convert.
Form data using the
GET
method can be passed at the end of the URL, for example:
http://servername/cgi-bin/htmldoc/superproducts.html?name=value
Server-Side Preferences
When run as a CGI program, HTMLDOC will try to read a book file to set any preferences for the conversion
to PDF. For the superproducts.html file described previously, HTMLDOC will look at the following URLs
for a book file:
http://servername/superproducts.html.book
http://servername/.book
http://servername/cgi-bin/.book
The first book file that is found will be used.
Configuring HTMLDOC with Apache
The Apache web server is easily configured to use HTMLDOC. The simplest way is to copy or symlink the
htmldoc executable to the configured cgi-bin directory. For example, if your Apache installation is
configured to look for CGI programs in the /var/www/cgi-bin directory, the default for Apache on Red Hat
Linux, then the command to install HTMLDOC on your web server would be:
ln -s /usr/bin/htmldoc /var/www/cgi-bin ENTER
If you are using Apache 2.0.30 or higher, you will also need to enable
PATH_INFO
support by adding the
following line to your httpd.conf file:
AcceptPathInfo On
Apache also allows you to associate CGI programs with a specific extension. If you add the following line to
your httpd.conf file:
AddHandler cgi-script .cgi
and enable CGI execution with the
Options
directive for a directory:
Options +ExecCGI
then you can copy or symlink the htmldoc executable to an alternate location. For example, if you have a web
directory called /var/www/htdocs/products , you can install HTMLDOC in this directory with the following
command:
ln -s /usr/bin/htmldoc /var/www/htdocs/products/htmldoc.cgi ENTER
HTMLDOC 1.8.29 Software Users Manual
5-2
Using HTMLDOC as a CGI Program