Many web applications using PDF documents for invoices, contracts and many other doc types. There are a few PHP classes which are able to create PDF documents online, one of them is TCPDF. This tutorial is about how-to use the TCPDF class while creating a simple invoice document. If you like to take a sneak peak on the result, check this website which generates the PDF Invoice document on the fly.
They show how, with a bit of sample code in a class, to create a basic invoice pulling in an image for the header and putting a short sample string in the footer. From there, the class can be used to wrap header information (like contact details) and the rows of the invoice (payment and charge information) inside the template.