Forums

Simple library to create PDF file from zero

Is there any installed library to use it to make pdf like this:

from fpdf import FPDF
pdf = FPDF()
pdf.add_page()
pdf.set_font("Arial", size=12)
pdf.cell(200, 10, txt="Welcome to Python!", ln=1, align="C")
pdf.output("simple_demo.pdf")

I'm aware of https://help.pythonanywhere.com/pages/PDF/ am but not clear of simple solution.

I've used weasyprint library, composing html and making PDF of it.

That sounds like a good solution.

ReportLab is also installed on PythonAnywhere - it isn't listed in the packages list, I guess it got installed as a requirement from something else. I've found weasyprint to offer better support for embedded SVG graphics, though, if that's something that might be important for your application.

There is also Abiword, which will allow you to produce PDF documents from .DOCX mailmerge templates.