At a previous job I needed to automatically populate form fields in a PDF template and then ‘flatten’ the PDF so that users could make no further changes. After asking on StackOverflow (Populating PDF fields from a database), I came across a piece of software called iText which provides this functionality. The only downside was that it was licensed under the AGPL, which would require us to open source our entire codebase. To get around this, I wrote a web service called FormFillFlatten which accepts a PDF and a JSON string (with name/value pairs of the form fields) and returns the completed PDF.
If you think this functionality would be useful in your projects, the code and documentation is available on GitHub.