Xhtml2pdf HomePage
Presentation
Xhtml2pdf is a small... no ok it's not that small. So, xhtml2pdf is a PHP class based on
the excellent FPDF class, which allows to convert xhtml
files to pdf files, using a css file. In fact what's really great about it is that it doesn't
require any additionnal program or library, so it should work on almost every webhost. What
for? I don't know. In fact, I began to code this for fun, because it could be done and had
never been before. But as I don't like not to finish such a beautiful piece of code, I did
some improvement to my first code :D.
Greaat !
In fact, no.. Xhtml2pdf (I'm really bad at finding new names to my projects :D) may NOT
be the perfect program you are looking for. So here is what it does (more precisely, what it
does NOT do) so I won't get so much complaints later.
- It can NOT convert HTML files, and it never will. It's easy (hum, that's relative) to parse
xhtml. But parsing a HTML file is really not that easy. Many program do it, I don't.
- It implements only VERY FEW css properties. Why? Because Fpdf has at this time quite a lot
of limitations. And I _really_ don't want to recode FPDF. You can get the supported properties
and values here.
- Some HTML elements are actually not implemented, like tables or pictures. They might be soon,
but maybe with some simplification.
- Xhtml2pdf does NOT (actually..) read the presentation attributes of the html elements. All
presentation data should be put in a separate css file.
So, now you know what xhtml2pdf can NOT do. But, assumed all these problems, it can dynamically generate
really nice simple pdf files, easily customisable with a simple css file :).
Download
Supported CSS attributes
- font-size, given in px, pt, cm, mm
- color, given in #rrggbb,#rgb, RGB(,,) (should work..)
- font-weight, bold | normal
- display, block | inline
- text-decoration, underline | none
- text-transform, uppercase | lowercase | capitalize | normal
- white-space, normal | pre
- margin-bottom, given in px, pt, cm, mm
- margin-left, given in px, pt, cm, mm
- margin-top, given in px, pt, cm, mm
- font-style, normal | italic