6
8 Comments

How to Automate Dynamic PDF Generation

Use API written on a white board
Production challenges with dynamic PDF generation can set organisations back significantly. This PDF generation article reviews the possible technology options available. The three approaches are:

  • HTML to PDF
  • Word to PDF (or similar)
  • New innovative approach of using LaTeX through an API

Do you know any other methods of creating bespoke PDF documents with changing underlying data?

  1. 3

    We experimented with different options on backend. Initially we followed a simple approach converting HTML/CSS but we faced issues with the quality and the time spent to actually design the PDF.

    We still believe that converting HTML/CSS to PDF is the way to go, at least for our use case. We are currently checking Puppeteer (with headless chrome) and evaluating the pros/cons.

  2. 2

    I built a service that does exactly this https://cloudlayer.io I mentioned it a couple times on here. If you need a feature or anything that isn't offered, ping me and I will get it added! Also, worth mentioning our next release is adding the templating capability, and hope to get a UI to let you build your own templates. Currently we are prototyping that out internally and looks promising.

  3. 2

    On my last project, I've used HTML/CSS ( & Tailwind) together with EJS for templating, and Puppeteer (headless Chrome) to export to PDF.

    This combo works great, and is very flexible. What is less fun is page headers/footers.

  4. 2

    We've investigated a number of different solutions, and have found that there is generally no perfect option - they all have compromises (surprise!). The key considerations are:

    • Are you generating PDFs on the backend or frontend?
    • What kind of dynamic content do you plan to insert into PDFs?
    • What level of design control do you need?

    Here are some other references to PDF generation resources. We investigated pagedjs, but are likely to stick with react-pdf for now.
    https://pdf.math.dev/
    https://www.pagedjs.org/
    https://www.npmjs.com/package/react-pdf

  5. 2

    We spent a lot of time with this problem when building Afloat. We generate dynamic invoices from our WYSIWYG invoice editor.
    Our first iteration involved https://pdfkit.org/ for generating pdfs, this lead to a lot of extra code and data. We also felt that it was pretty unreliable. The latest version is 0.12 and has 301 issues on Github.
    We finally went for the HTML to PDF method, which has worked really well. Your API seems really interesting though, till definitely keep an eye on it in the future.

    1. 1

      Thanks for the feedback. Please do not hesitate to get in touch if you would like to see a demo.

  6. 2

    I built a tool to for non-technical people to create PDF templates that could that be dynamically generated with API but I struggled to market it.

    1. 1

      We can relate to that. We are trying different marketing approaches at the moment to figure out what is working and what is not.

Trending on Indie Hackers
A Tool to Quickly Scaffold Custom SAAS Projects 18 comments We bootstrapped our SaaS to $50k MRR with just me and my co-founder - no employees 13 comments I just released my no-code SaaS product - show some love? 10 comments I bootstrapped an encyclopedia on nutrition to 7-figure ARR — AMA! 6 comments How to start a podcast in 2021? (Part 1: Idea & Format) 5 comments KatLinks launch is live on Product Hunt ⚡ 4 comments