Generating PDF invoice from Form Submission using a custom script

This is a guest post from long term Simfatic Forms customer Pierre Linssen.

Pierre managed to add a PDF invoice feature to his forms using the extension modules feature. The code could be useful to other users who want similar features. Thanks, Pierre for sharing the code and for the write-up.

On to the post …


Introduction

My name is Pierre Linssen, born and raised in the Netherlands and for 10 years living and working in Germany.

In my daily life, I am working as a self-employed interim manager, program manager and coach in various areas like energy, security, finance and IT.

As a hobby, since the year 2003, I am also the webmaster of www.tukhut.nl, a mountain house of the NKBV (the Dutch mountain climbing association).

In the summer of 2010, for www.tukhut.nl, I wanted to get a dedicated subscription form online.

At that time I had to decide: either do it all by myself or scan the market to see if there were suitable software solutions available to create the desired form.
And I definitely found one! That was when I first got in touch with Simfatic Forms. At that time, Prasanth assisted and supported me in getting some sophisticated input validations implemented.

Ever since then, so already almost 10 years ago, the Tukhut subscription form, with some additional improvements, flawlessly has been doing its job.

Excellent support!

During the last 10 years, every now and then, I had some specific questions related to the deployment of various with Simfatic Forms created and implemented forms.

And I really must say: Prasanth has always responded to my questions very fast. And together we have always found appropriate solutions for some smaller and for some bigger challenges.
Thank you very much, Prasanth, for all your swift support during the past 10 years !!!

A recent Simfatic Forms project

Recently one of my clients in the Netherlands, who is organizing and giving several workshops and training, wanted to have an application implemented with the following key demands:

registration/subscription for various workshops/trainings, with:

  • automatic generation of a response e-mail to each subscriber
  • automatic generation of an e-mail with attached PDF-invoice to each subscriber
  • automatic generation of a received subscription e-mail to the workshop organizer
  • automatic generation of an e-mail with attached PDF-invoice copy to the workshop organizer;
  • automatic database registration of each subscription, to facilitate future communication with workshop subscribers.

Time to pay it forward …

So I guess now it is time to share a demo-project with you, based on the above-mentioned project.

Obviously, the demo- form itself has been generated with Simfatic Forms.

You can download all my project files here
pdf-invoice-sample.zip

The pdf-invoice-sample.zip contains the following files:

  1. The Simfatic Forms project file. (subscribe_workshops.fwz)
  2. a specific extension module that has been integrated with Simfatic Forms. (post-to-another-form-extension-module.php)
  3. a dedicated PHP file for PDF invoice generation, importing variables from the form, handling of those variables,
    creating the format for the PDF-invoice, creating the PDF-invoice itself and sending out the PDF-invoice via e-mail. (workshop_invoice.php)

In addition to the files above, you need additional supporting files for the PDF generation. Details below:

  1. FPDF, a PHP-class that arranges the generation of a PDF-document. The needed FPDF files can be found here …
  2. FPDF easyTable, another PHP-class, facilitating the creation of tables in PDF-documents. The needed easyTable files can be found here …

Steps

  1. You have to edit the workshop_invoice.php file in a text editor and replace you@website.com with your email address.
  2. Upload the file workshop_invoice.php to your website making it available at an address like http://your-website.com/workshop_invoice.php. You will have to upload the additional supporting FPDF files also in the same folder.
  3. Edit the extension module post-to-another-form-extension-module.php in a text editor. Update the URL of the script to the correct URL from the last step (http://your-website.com/workshop_invoice.php)
  4. Open the Simfatic Forms project file (subscribe_workshops.fwz) in Simfatic Forms. Enable extension Module (Form processing options page). Press Next and add the updated extension module (post-to-another-form-extension-module.php) in the extension modules page
  5. Proceed to upload the form

I hope you find this script useful.

Any questions?
Just email me (Pierre Linssen) info {(at)} aeternus.org.