7
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?

on June 21, 2021
  1. 4

    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
Hi IH — quick update. The MVP is live. User Avatar 32 comments Building ExpenseSpy solo, no funding — launching June 17 on iOS & Android User Avatar 25 comments Day 7: 51 people answered my question. I wasn't ready for what they said. User Avatar 18 comments I Built a Football Sentiment Platform in 18 Days. The World Cup Starts in 7 Days. Now I Need Distribution. User Avatar 17 comments Built an n8n booking alert system — is cold outreach dead for B2B micro-tools? User Avatar 16 comments I built a $5/1k-listing CRE data API because CoStar is overkill for first-pass scans User Avatar 14 comments