I had some fun this weekend having a go at pdfkit with mixed results. Can anyone nominate a candidate for best PDF writing?

I am not using such right now but a buddy is and pdfkit works fine.
What do you mean by mixed results?

commented: answered you below where I had more space, thanks. +1

@rproffit

Hey nice to hear from you. So when I try pdfkit the from_file method it doesn't work, giving me the error:

    pdfkit.from_string(report, '/tmp/out.pdf', options=options)
  File "/usr/lib/python3/dist-packages/pdfkit/api.py", line 72, in from_string
    return r.to_pdf(output_path)
  File "/usr/lib/python3/dist-packages/pdfkit/pdfkit.py", line 156, in to_pdf
    raise IOError('wkhtmltopdf reported an error:\n' + stderr)
OSError: wkhtmltopdf reported an error:
QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-service'
Error: This version of wkhtmltopdf is build against an unpatched version of QT, and does not support more then one input document.
Exit with code 1, due to unknown error

But it works with a string (using from_string), yielding a decent-looking PDF, provided that my HTML doesn't attempt any images.

I just patched my dev system and uname gives:
Linux 5.15.0-91-generic #101~20.04.1-Ubuntu SMP Thu Nov 16 14:22:28 UTC 2023 x86_64 x86_64 x86_64

Maybe I'm better off rendering in docx format and converting to PDF from there? My major constraint is that I'm trying to avoid hackish solutions. I want to stick as close to stock Ubuntu/Red-Hat as possible.

Hence both wkhtmltopdf and pdfkit as strong contenders, both of them being in the repos.

commented: Here's the thing. Setup and code can be challenging. I've yet to find fixes for that. +17

Great.

commented: Just vote next time, not bump with a 1-word post count padding -4

I've had pretty decent experience with xhtml2pdf. The best part about this PDF library is that you don't have to worry about the low level nitty-gritty of PDF creation, you can simply generate a PDF from your HTML formatted content.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.