PDF generation from code

Oh boy. We're going to have to start making PDFs from code. They need to have fairly complicated formatting — the result needs to mimic something that was originally designed in MS Word and then saved as a PDF.

Anyone got any suggestions or advice?

Design in HTML and then render to PDF with PhantomJS?

Make the documents as HTML and convert to PDF with wkhtmltopdf?

The PDFKit Ruby library does this, using wkhtmltopdf in the background.

An older-school suggestion: PostScript? PDF is just stripped-down PostScript (thanks, Adobe!). Of course, whenever I flirted with PostScript, I found a way around having to actually write my own PostScript instead of ever learning it, despite my advisor's insistence.

If not that, maybe some other type-setting language like LaTeX which is more like a programming language that can easily be piped into a PDF converter.

I've used Crystal Reports to generate PDFs. The creation interface is featured enough that non-developers could make changes once the original data setup is done, but it can be crashy and whoever is using it needs to be trained if it is more than a mail merge-like form letter. Using their API through .NET is a bit confusing to say the least, and you have to have the Crystal Runtime installed on your server generating the PDFs. I've had tons of problems with the runtime over the years when switching to 32 to 64 bit and .NET versions, but lately it has been fine.

I've also used EVO HTML to PDF and Winnovative HTML to PDF Converter where basically we generate the form in HTML and spit it out in PDF with these APIs. These options are nice in that you need the assembly (and the EVO version needs a helper "dat" file) but you don't have to install a runtime. Your forms have to be simple enough that you can do it in HTML, and unless you have a web designer a developer may have to make changes unless you make it customizable somehow. Both of these components are by the same company but have completely different websites for some reason. The EVO version works with SVG and I believe has its own web rendering engine built in. The Winnovative version uses the .NET WebBrowser object which just uses the IE browser installed on the server. That's caused us problems when we upgraded Window Server versions (which changed the IE version installed) and suddenly things got rendered differently.

What technologies are you using? I can show you an example of how I generate pdf's for an ASP MVC site using microsoft report viewer.

Adobe has an official SDK, maybe that might be worth exploring?

There's Reportlab if python is your cup of tea.