since your source is a database, an alternative is going the whole hog, and get a report generator product suitable for your DB. Report generators have the capability to produce invoice and other summary reports, and can output in a variety of formats, including pdf usually. crystal reports is probably overkill and costly, but there are opensource alternatives. search for "report" in a opensource project repository.
in reply to PDF vs. HTML for invoice generation
the hardest line to type correctly is: stty erase ^H