Automatically Generate PDFs with Gravity Forms and Gravity PDF

Gravity PDF

I’m back with another look at a Gravity Forms powered WordPress plugin. Gravity PDF is a no-brainer idea when you think about it. The plugin generates PDF documents from Gravity Forms submission data. The real selling point is the ease of use Gravity PDF provides and it’s extendibility with a set of custom add-ons and templates available for sale from the developer.

Jake Jackson, from Blue Liquid Designs, answered my questions about how Gravity PDF was conceived, the struggles with writing code to format and build PDFs, their revenue generating template system and how he markets the plugin to such a wide potential customer base.


Can you start by telling me a bit about yourself and the team behind Gravity PDF?

My name is Jake Jackson and I’m the Head Developer of Gravity PDF and business owner of Blue Liquid Designs. We’ve a small team of two (myself included) working on Gravity PDF and are both based out of Port Macquarie, New South Wales, Australia. I’ve been working on the project since its inception in 2012 and my associate, Julian Tapping, has been involved since mid-2013. Julian and I work remotely from home (even though we live a five-minute drive from one another) and we use tools like Trello, Slack, Help Scout, and WordPress of course, for communication and management.

Six years ago, when Gravity PDF was first released – back then it was called Gravity Forms PDF Extended (quite the mouthful, I know) and WordPress 3.3 was just released – I was a green 21-year-old with plenty of enthusiasm, but not a lot of direction. Thinking back, the term cowboy coder would apply. I still remember tracking down bugs using the old `print_r($variable); exit;` method. Thankfully, those days are over, and a big part of that is because of the early success of Gravity PDF. Today I spend more time using Xdebug and writing unit tests than I do writing the code that I’m tested, and that’s a very good thing. I also co-organise the Port Macquarie WordPress meet-up with Robey and Mel Lawrence.

Outside of the business world, I’m heavily involved in volunteer work with the New South Wales Rural Fire Service – my respect for volunteers and not-for-profits/charities in general is a major reason for offering a 50% discount from our online store. I enjoy activities like surfing, dirt biking and four-wheel driving, have just bought my first home, and am about to become a parent in June – it’s a boy!

What was the inspiration for Gravity PDF?

The usual reason for a new piece of software: necessity. I was doing freelance web development at the time and a client wanted their contact form results to be sent via email as a PDF document. They were using Gravity Forms, and a quick search online yielded an open source plugin called Gravity Forms PDF – written by Russell Osborn – which allowed print- friendly PDFs to be generated from the WordPress admin area.

The only problem was it didn’t have any email functionality, so I forked it and added basic email attachment support via a simple code snippet. I ended up releasing the software on WordPress.org in the hope that other developers would find it useful. It turned out to be far more popular than I ever could have expected – not only with the primary target market, developers, but also with implementors and DIY business owners – and has been steadily growing ever since.

Gravity PDF Screenshot: Focus Template
Gravity PDF comes with free templates, like this one called Focus, out of the box.

I’ve spent a fair share of programming hours over the years building PDF generation scripts and things for clients. It can sometimes be a bit of a nightmare. What are some of the biggest technical difficulties you have to deal with when developing and growing Gravity PDF?

You’re not wrong. The PDF Reference manuals are very dry reading! The major challenges we’ve faced since inception has always been related to the PHP library used to generate the PDFs. In the early days, we were using the dompdf library to generate the documents. Back then, the library was lacking Unicode support, as well as important layout-related features like floats and nested tables (although a quick look today shows improvement in all these areas), so I started looking for alternative options. That’s when I found the mPDF library – originally developed by Ian Back – which had everything I was looking for (and more). After thoroughly vetting the library, it was rolled into Gravity PDF 3.0.

mPDF hasn’t been without its own problems though. Having full Unicode support meant 46 font files, totalling 19MB, had to be uploaded and shipped with every release. The original number of fonts was actually 70, totalling 86MB, but I forked the library and stripped out the larger fonts (mostly for the Chinese, Japanese and Korean languages) to help reduce the overall package size. Even with the reduced font-set, users on low-resource shared hosting providers had issues upgrading the plugin due to timeout or memory issues. Thankfully, with the rise of managed WordPress hosting, and the speed improvements found in PHP 7, this issue has been greatly reduced.

Still, by cutting back on the fonts being included we’re intentionally reducing the languages we support out of the box, and I haven’t been happy with that solution. That’s why in Gravity PDF 5 (currently in development) all fonts have been removed from the plugin. Instead, users will run a one-time installer upon activation to download the fonts to a folder which will survive plugin updates. Adding this step does add friction for first-time users, but the long-term benefits out-way this minor inconvenience.

Another major problem has been the long-term viability of the PDF generation software we use. Within two years after switching to mPDF Ian Back discontinue the project – talk about betting on the wrong horse! Thankfully, open source being what it is, the project got adopted by Matěj Humpál who, along with 37 contributors to date (myself included), have been slowly converting the outdated, legacy PHP code into a modern library. There’s still a lot of work to do, but it’s leaps and bounds ahead of where it came from. I’ll be dropping the fork we currently maintain in favour of the upstream version for Gravity PDF 5.

It’s good timing too, as on PHP 7.1 and 7.2 the fork is starting to show its age, with numerous PHP warnings and notices triggered during the PDF generation. The only saving grace is the best-practice of disabling error reporting in a production environment, which has provided temporary relief while we work on creating a successful migration path for our existing users.

Gravity PDF Screenshot: Preview
Gravity PDF lets you view PDFS before form submission is completed.

One of the interesting things about your business is that not only do you use the popular extensions model (freemium) but you sell PDF templates as well. Has that proven to be a popular revenue option for you? Did the idea for templates come naturally to you or was it based on customer requests?

When the plugin was initially released, the question that got asked most often was how to create a PDF in a specific format, or how do I create multiple PDFs in different formats. The initial answer was you couldn’t easily, but I could see the benefits of this functionality and so support for custom templates was quickly added. For developers who had knowledge of HTML, CSS and PHP, this was an excellent step forward. However, I found myself getting an increasing number of emails from business owners who didn’t have the knowledge or time to create the PDF templates themselves, and so I started offering a service to build it for them.

In the early years, this unique revenue stream was the reason Gravity PDF continued to grow. It’s why after only three years as a side project I made the decision to go all-in and make Gravity PDF my primary business. To do that successfully required a heavy investment from my part, and I spent 18 months rebuilding the plugin into what you see today.

In the months leading up to the re-launch I remember struggling over which revenue model to pursue going forward: a premium or a freemium model. Switching to a premium model and charging for the software upfront would see the quickest return on investment and provide the financial stability needed to ensure the long-term viability of the plugin. But it would be a slap in the face to all the existing users (between 5000-10000) who had been using the software freely for years – or worse, had paid for a custom template. It would also go against the software’s original intention: a free tool to help developers generate PDFs using Gravity Forms for their clients. In the end I decided the freemium model – where the core software is free and paid add-ons are available – would better align with the original, and long-term goals of the project. In the last 12 months we’ve released 13 premium PDF templates, and two extensions, with plans for much more to come.

Gravity PDF Screenshot: Zadani Template
Zadani is another free template included with Gravity PDF.

How do you go about marketing Gravity PDF? It seems like this is something almost every business using Gravity Forms would find useful.

The most effective marketing we do has always come from organic sources, and because we use the freemium model we can publish the plugin in the WordPress.org repository. Every site owner running WordPress can search the repository. Try to search for a PDF plugin and you’ll find us on the first page of the results. If you get more specific and search for a Gravity Forms PDF plugin we are the top result.

Aside from the repo, creating a product for a niche market with little competition is a major strength. You know exactly who your market segment is and can more easily target those users. Every business running WordPress and Gravity Forms would find the software useful. So, when it comes time to solve the problem of generating a PDF using Gravity Forms one of the first products our users come across is Gravity PDF.

In the last few years I have started seeing more competition in this space, but all the solutions to date have not directly threatened Gravity PDF. Why? Because of the core features which I believe make Gravity PDF truly unique:

  1. Gravity PDF works on all modern PHP hosting environments. No special software needs to be installed on the server.
  2. Gravity PDF generates PDFs on your website’s web server. Your entry data is never sent to an external server. GDPR Data Protection Officers eat your heart out!
  3. Gravity PDF can generate an unlimited number of PDF documents every month without costing you a cent (well, any more than your web hosting fee).
  4. Gravity PDF can generate conditional PDF documents, allowing the PDF to expand to fit the user’s responses.

Is there any one piece of advice you wish you could give yourself, or tell someone else building a Gravity Forms-related plugin right now, that you wish you had known before you started Gravity PDF?

It’s not Gravity Forms-specific, but using version control and writing automated tests before releasing any software publicly will save you (and your users) a lot of headaches. A proper IDE like PHPStorm with built-in Xdebug support also goes a long way in helping you write quality code.

What’s next for you and the team at Blue Liquid Designs?

Right now, Gravity PDF has a large roadmap, so the long-terms goals are to ship those features. There’s no plans to branch out into other form-builder plugins, but if we get the formula right for Gravity Forms, and a cost-benefit analysis reveals it’s a viable option, then it’s possible we could build integrations for other form-builder plugins in future. However, I don’t like to get tunnel vision when it comes to the long-term planning; I feel this allows the business to more-quickly respond to customer expectations and changing market conditions.