Generate document from templates and database

I'm looking for a solution to generate document (ideally docx but pdf is ok) from a database

Ex: I have a project entry (with client info, dates, information about the project, etc.) and I want to generate documents from a tender templates, containing selected entries from the database.

Here is what I tried until now :

  • Custom database (tinyDB) + custom webpage form + a docx template with jinja markups served by a homemade webpage hosted on pythonanywhere (lot of work and not reliable as I'm doing everything myself)
  • Nocodb form and database (no document generation yet) (self-hosted or on cloud)
  • Airtable (closed source and on cloud) for forms, database and document generation

Airtable is what I'm currently trying because it's the only one that I found that have lot of support and adds on.

There are a few options on Airtable for document generation, lot of which cost around $30/month which is why I'm looking for a viable alternative. Ideally I would like to be able to upload my already made templates.

More point to the solution if it's supports geodata

I'm considering keeping airtable and using the api to generate document with the python program I used on the first point, but I'd like to know if there is more options.

Edit: precision: I need to create a document that contains multiple items of the db.
Ex: I need to create a resume with different experiences that are saved in the database

Here is an example of a template:

https://lemmy.world/pictrs/image/ece26e50-1789-4464-b284-3bc597ee09ed.png

Ekpu ,

I am searching for a similiar Software. Ideal would be a low code database platform selfhostet with easy document generation. I am still searching but you can take a look at https://rei3.de/en/home.
Low code and database works good. The document generation is a bit hacky but you can fill placeholders oft a HTML side.
But they hinted that they will have to work in this because the library they used is no longer supportet. So I hope it will geht easier.

Plus side it comes with user management and some "apps" out oft the box and all oft the "apps" are interoperable. Self created apps are Versionen out oft the box and you have to sign them with a generated developer key which is also very nice.

Ekpu ,

I had another idea. Maybe Dokuwiki with the struct and burocreacy Plugin would could work for you.

ericjmorey ,
@ericjmorey@programming.dev avatar

I'm very confused about what your requirements are based on reading your post and some of your responses to comments, but I'm going to suggest that you look into Quarto

____ ,

As part of a much larger project that was all-in on Java to begin with, I've used Tomcat to serve pages and PDFs/office doc formats rendered based on a postgres backend and FreeMarker templates.

For these purposes, you don't want that level of complexity (or Java) but the general premise and template libs should be available in nearly any sane web programming language.

stuner ,

Is using Latex an option? I've done that and it works quite nicely. You can easily populate a template e.g. using Python.

Biorix OP ,

It is, but the main issue is how to select the values from the database and to render without the user needing to tweak anything

Latex, MD, Word is equivalent (although Word is preferred) since I'll just place universal markers in it

stuner ,

One way to do it is have a small Python (or any other scripting language really) script that performs text replacements in the Latex source file. This is much easier in Latex because it's plain text. I don't know of a solution that doesn't involve writing your own code (apart from LO/Word serial letters).

megaman ,

Ive got some stuff that i think is similar to what you are trying where i have an excel file template and use python to read from the database and populate cells in excel and then save a pdf.

There are a couple different options for python libraries - openpyxl, xlwings, or pywin32.

It is annoying and goofy, but works. Excel can be very flexible with getting everything sized just right for what your final output/pdf should look like.

Biorix OP ,

Thank you !

It's pretty much the solution I already have: I generate a doc with DocxTemplate through a webpage made with Flask.

What I'm looking for is a solution with a user-friendly pipeline that can be easily used by anyone once it's set up

Form > generate new entry in a db

Entry > Select entry from tags > generate documents from template

Airtable is already proposing something similar, which is why I'm currently trying it with zapier, Documint, and other automation solutions

I'm looking for a self host solution but mostly a free and polished one

florian ,

I seems a long time ago, I build the same thing as you. For templating I used https://github.com/christopher-ramirez/secretary and as "database" I used Google sheets. Still use it at work.

It never was really user friendly so I am looking to replace it. That is also the main issue with your self build solution? Or are there other issues as well?

I didn't know about Documint. Looks interesting, will check it out, thanks 👍

Jackinopolis ,

I've been using ReportLabs to make pdfs in Python. It took some getting used to but I can put together just about anything I can imagine. I still get a little lost when I need to dig into the source code and how it generates pdfs from templates though.

atzanteol ,
Biorix OP ,

Interesting! I'll take a look
Although, I'm not sure if I'll be able to implement it in my company.
Thanks!

slazer2au ,

This may to against self hosting but doesn't MS Word have this capability?

Biorix OP ,

Yes, it does have the same option that libreoffice. But this solution would not be better than what I have currently

tagginator Bot ,

New Lemmy Post: Generate document from templates and database (https://lemmyverse.link/lemmy.world/post/15688733)
Tagging:

(Replying in the OP of this thread (NOT THIS BOT!) will appear as a comment in the lemmy discussion.)

I am a FOSS bot. Check my README: https://github.com/db0/lemmy-tagginator/blob/main/README.md

  • All
  • Subscribed
  • Moderated
  • Favorites
  • [email protected]
  • kbinchat
  • All magazines