In my case I want to generate a PDF in memory in our Flask app so I can directly send it to the user as download instead of saving it to disk first.
Our code now:
import os
from reportlab.pdfgen import canvas
from reportlab.lib.pagesizes import A4
# normally this in a class but I simplified it for the example
c = canvas.Canvas(os.path.join("mypath", "report.pdf"), pagesize=A4)
c.drawString(100, 100, "Hello World")
c.save()