# Introduction # PyFPDF now supports basic HTML, mainly intended to write reports from web frameworks. It understands a limited subset of the HTML language, and it doesn't support advanced features nor CSS (look below). HTMLMixin could be used along with FPDF class to implement this functionality (see the example). Sample: [html.pdf](http://pyfpdf.googlecode.com/files/html.pdf) # Details # HTML tags and attributes supported: * H1 to H8: headings (align attribute) * P: paragraphs (align attributes) * B, I, U: bold, italic, underline * FONT: (face, size, color attributes) * CENTER for aling * A: links (href attribute)) * IMG: images (src, width, height attributes) * OL/UL/LI: ordered, unordered and list items (can be nested) * TABLE: (border, width attributes) * THEAD: header (opens each page) * TFOOT: footer (closes each page) * TBODY: actual rows * TR: rows (bgcolor attribute) * TH: highlight cells (align, bgcolor, width attributes) * TD: rows (align, bgcolor, width attribute) Note: Tables should have at least a first TH row with width attribute. # Example # ``` html = """

html2fpdf

Basic usage

You can now easily print text mixing different styles : bold, italic, underlined, or all at once!
You can also insert links on text, such as www.fpdf.org, or on an image: click on the logo.

Sample List

Header 1header 2
cell 1cell 2
cell 2cell 3
""" from pyfpdf import FPDF, HTMLMixin class MyFPDF(FPDF, HTMLMixin): pass pdf=MyFPDF() #First page pdf.add_page() pdf.write_html(html) pdf.output('html.pdf','F') ``` See html.py or Web2Py for a complete example