If you're looking for a PHP solution, try the Zend_Pdf component in the Zend Framework library.
http://framework.zend.com/manual/en/zend.pdf.html
I'm not sure how tightly coupled it is with the framework, but you might be in luck. Some components are easy to remove and others aren't. Take a look either way. Worst case, you can use some of the code.