About Sitellite       Screenshots       Downloads       Forge      Documentation       Community       Support

You are here: Home / Documentation / PDF Output in Sitellite

PDF Output in Sitellite

One of the lesser-known features Sitellite offers is the ability to output to more formats than just plain-old HTML.  This is achieved through a concept called "output modes" (see my article How To: Templates In Sitellite for more information about output modes), which allow you to specify one of multiple templates to use for formatting a single page.  We'll take this a step further today and create an output mode that we will then transform into a binary file format: a PDF.

What we'll do to format the PDF is as follows:

  • First, we'll need to install a special command-line utility on the server called HTMLDoc.
  • Next, we'll create a new 'pdf' output mode by creating a template file inc/html/mytemplates/pdf.default.tpl
  • Then, we'll add the necessary HTMLDoc formatting instructions to our new template.
  • Now we can call the web site using the sitellite/util/pdfmaker box, which will output the specified page as a PDF.
  • Repeat steps 3 & 4 until satisfied with yoru output.
  • Finally, we'll add a link to our main template or a sidebar box so that our web site visitors can access our new PDF-ized web site.

Step 1: Installing HTMLDoc

HTMLDoc is an open source utility for converting HTML pages into PDF files.  This takes care of the hardest part -- making the PDF itself -- and has the advantage of allowing us to style our soon-to-be PDF files in plain-old HTML, which I'm sure most of us are more familiar with than the PHP PDF API (now that's too many acronyms!).  The HTMLDoc web site is here:

http://www.easysw.com/htmldoc/

Once you've downloaded the software and then uploaded it to your server, you can install it with the usual set of commands:

$ bunzip2 htmldoc-1.8.3-source.tar.bz2
$ tar -xf htmldoc-1.8.3-source.tar
$ cd htmldoc-1.8.3
$ ./configure
$ make
$ su
(enter password when prompted)
# make install

Or if you don't have root access, you may be able to install it into your own home directory by specifying:

$ ./configure --prefix=/home/USER/bin

Of course, you'll want to read the actuall installation instructions before proceeding.  The offical installation instructions are here:

http://www.easysw.com/htmldoc/htmldoc.html#2_2

You'll know you've got it installed if you can type 'man htmldoc' and read the HTMLDoc command line instructions.

Page 1: Step 1: Installing HTMLDoc
Page 2: Step 2: Creating a New Output Mode
Page 3: Step 4: Calling the PDF Maker

All Tutorials

Members

Note: You can use your SitelliteForge.com account here and vice versa.

Username

Password

Forgot your password?

Not a member? Click here to register

Sitellite 5 Beta


Copyright © 2008, SIMIAN systems Inc.
All rights reserved. Privacy policy
Some of the icons on this site were created by the Gnome Project.