I keep running my head into a wall working on a project and I am hoping you guys can help me. I have created a database that contains the addresses of contacts. What I need to accomplish is generating paper reports of these addresses. So, for example, I may have 25 addresses on one report related by some other data point. I figured that I should easily be able to pull info from my database and fill a PDF template with it that I could then print out, but this has proven harder than expected.

So far, I’ve tried airtable and notion (I know, but I was temporarily having server issues and I need to get this project done) I’ve also tried baserow and nocodb, and yet I can’t seem to figure out how to generate printable reports from my data.

Does anyone else know of an option? I’ve seen a recommendation for creating a spreadsheet or word document as a template that you then copy/paste your data into, but that feels… inelegant? Would something like appsmith or budibase be capable of this? Or is there some other (preferably self-hosted) software to accomplish this? I appreciate any help you can give me.

Edit: Sorry everyone, I guess I didn’t make it very clear. First off, I’ve been using the programs above to make my dB’s. So for instance, my nocodb is set up to use mysql. I didn’t generate the dB on my own, and admittedly, I’ve never interacted with a db directly using SQL markup before.I was hoping my goal could be accomplished with a low/no-code option as my coding skills are rudimentary right now.

As someone asked, for a printable-report, yes PDF is an option. As would a word document or spreadsheet, for that matter, just so long as I can get it into a nice, print-friendly format.

I do appreciate all the suggestions so far, and will look into them. Thanks!

  • Max-P@lemmy.max-p.me
    link
    fedilink
    English
    arrow-up
    6
    ·
    1 year ago

    Another option for generating PDFs would be to render to a web page and print that. This can be done fully unattended with wkhtmltopdf.

    You can easily use whichever programming language you’re familier with to render that HTML.

    Otherwise some database clients have the option to export to CSV, which you can then import or copy paste into a spreadsheet and print that.

    • froodloop@lemmy.world
      link
      fedilink
      English
      arrow-up
      1
      ·
      1 year ago

      wkhtmltopdf

      https://wkhtmltopdf.org/

      Thank you so much! A long time ago I experimented with generating PDF files for job applications, because I needed layout capabilities and more than simple variable replacing, and while I found something and made it work, it didn’t support a lot of rather basic CSS. Which made me sad because I liked the concept of it (as much as I can ever like generating PDF files, anyway), and I love now knowing about this, it seems perfect :)

      • Max-P@lemmy.max-p.me
        link
        fedilink
        English
        arrow-up
        2
        ·
        1 year ago

        I had rolled my own PDF generator with an entire layout engine before I found this. I was disappointed but immediately threw it all away in favor of that, because it’s so much easier. It’s just soooo damn much easier to use than keeping adding features to a custom engine. It handles CSS print stylesheets pretty well too, so you get to do all your page breaks and everything and the output is pretty clean and usable.

        I think it does generate mildly heavier/complex PDFs but at least it looks great.

        PHP PDF libraries 10 years ago were awful.

  • MigratingtoLemmy@lemmy.world
    link
    fedilink
    English
    arrow-up
    4
    ·
    1 year ago
    1. I’m assuming you’re using a “normal” DB like MySQL/PostgreSQL.
    2. Select entries with common attributes (just search for the syntax to select rows based on attributes for your DB).
    3. Utilise a PowerShell script/Shell script/Python/any other language you’re comfortable with to parse the output from the DB into a file.
      • I mentioned PowerShell since you want to create an excel file, and using objects (assigning attributes to said object) might be easier to handle writing to a file with, rather than using regex/awk if you’re using Shell (although that’s fun in its own way).
    4. Write to file. PowerShell has modules to write to excel/csv, I don’t think a Shell script could do that as easily but you can definitely find a way (note that if you try using PowerShell on Linux, the modules I mentioned might not work).

    Cheers

  • vatinen@lemm.ee
    cake
    link
    fedilink
    English
    arrow-up
    2
    ·
    1 year ago

    You may want to look up Variable Data Printing (VDP) software, there’s plenty out there

  • TheInsane42@lemmy.world
    link
    fedilink
    English
    arrow-up
    1
    ·
    1 year ago

    I managed to find the format of docx files and setup an automated invoice generation for my customers. A docx file is actually a zip file, which you can unzip, change fields in the text with sed, zip to a new file and then convert to pdf (libreoffice plugin) before sending/printing. That’s on Linux though.

    When you want I can dig up that code. Querying the database and sending to a printer shouldn’t be Yhe main issue I guess.

      • TheInsane42@lemmy.world
        link
        fedilink
        English
        arrow-up
        1
        ·
        1 year ago

        Oh, 1st of all, I have to make a small correction, I use an odt as base document.

        You run this in the directory with the odt file and a temp directory t

        cd t
        unzip ../${document_template}.odt
        sed -i "s/ReplaceThis/${var1}/g" content.xml
        sed -i "s/ReplaceThisToo/${var2}/g" content.xml
        zip -r ../${document_target}.odt .
        cd ../
        libreoffice --headless --convert-to pdf:writer_pdf_Export ${document_target}.odt
        

        The file content.xml is the actual text of the document, the rest is just the dressing (formatting). What you need to do is make sure the text you want to replace (ReplaceThis in the example) is unique apart from the spots where you want the text to be replaced. Check the content.xml to be sure, but be warned, the content.xml is a 2 line file with line 1 being the xml header. (it’s a terrible layout of the xml) Use an file editor you know well to find the words you want to replace. Also, be warned, correcting small typos in the odt results in garbage in the content.xml. You need to replace the whole word as 1 action. (Editing history has it’s uses, but is an issue here)

        Instead of converting it to file you can print it as well. (DDG result)

        libreoffice --headless --print-to-file --printer-name the_printer_name --outdir /tmp ${document_target}.odt
        lpr -U username /tmp/filename.ps -P the_printer_name
        rm /tmp/filename.ps
        
        • Ceedling@compuverse.ukOP
          link
          fedilink
          English
          arrow-up
          2
          ·
          1 year ago

          Awesome! Thanks so much for taking the time to post. I’ll have to dig a little more into that, looks really interesting

  • inspxtr@lemmy.world
    link
    fedilink
    English
    arrow-up
    1
    ·
    1 year ago

    I’m not entire sure what you mean by “printable reports”. Would you maybe want to post an example sketch?

    Anyway, have you considered writing the variables to Latex maybe, then render that to PDF?

  • PanteraAtrox@lemmy.dbzer0.com
    link
    fedilink
    English
    arrow-up
    1
    ·
    1 year ago

    what do you mean by ‘database’ ? like ms access or sql?

    PowerBI can pull data from sql database, .mdb or .xls files and generate all manner of reports.