If you’re a developer building some kind of shopping cart or checkout mechanism, chances are you will have to provide functionality to generate invoices and receipts in PDF format. This can be a real hassle, especially if you’re deployed in a cloud infrastructure like AWS, Azure, or Heroku.
The easiest way to generate a PDF of an invoice or receipt is to assemble the invoice in HTML first. Once it is in HTML format, which would be great to show on the web page in the first place, you can send that HTML a PDF engine such as wkhtmltopdf or Headless Chrome. Both engines should be perfectly sufficient for generating simple invoices / receipts.
Some basic HTML for an invoice can be found on Github. I found this project which has a simplistic invoice / receipt available: https://github.com/sparksuite/simple-html-invoice-template. The code for the invoice is in this github gist below.
Test out the Invoice to PDF conversion in the DEMO on api2pdf.com by copying and pasting the HTML. The resulting PDF should look like the following:
Api2Pdf’s goal is to make the experience of generating PDFs for application developers not completely miserable. You can use Api2Pdf as your invoice / receipt PDF API by converting HTML to PDF at very low cost. Api2Pdf let’s you generate invoices and receipts on AWS Lambda.headless chrome, html-to-pdf, invoice, wkhtmltopdf
Comments are closed.