Creating PDF Invoices - Are there any templating solutions?

smashedmercury picture smashedmercury · Nov 7, 2008 · Viewed 18k times · Source

Our company is looking to integrate invoices into a new system we are developing.

We require a solution to create a layout of the invoice and then convert to pdf.

We have considered just laying out the invoice in html/css then converting to pdf. We have also considered using SVG->PDf conversion.

Both of these solutions integrate well into our existing templating language used for our web application.

Historically we have been a Microsoft based business and used Crystal Reports for such a task but we are looking for an open source Linux solution for this project.

Does any one have any suggestions of an approach or technology we could use for such a task?

Answer

Jason picture Jason · Nov 7, 2008

Try this... create a blank invoice with Word (or whatever you want) and save it as a PDF.

Then use a PDF library to modify the PDF (insert the text at particular coordinates). We do this in the Microsoft world and it is extremely easy.

The biggest benefit is that we can use our own tools to create and modify the template. If we want to add some static text, we just crank open Word, make the change and save it to a PDF file (that is being used as a template).

For Microsoft, we use iTextSharp which is actually a C# port of the original Java version of iText


Additionally...

You can use Adobe Acrobat to insert fields in the PDF (address, phone, invoice number, line item 1, line item 2, etc...) and then use iText/iTextSharp to populate these fields at run time.

This is, in more detail, what we do... and it is extremely easy.