Here is my experience after following the hints on this page.
pyPDF can't embed images into files. It can only split and merge. (Source: Ctrl+F through its documentation page) Which is great, but not if you have images that are not already embedded in a PDF.
pyPDF2 doesn't seem to have any extra documentation on top of pyPDF.
ReportLab is very extensive. (Userguide) However, with a bit of Ctrl+F and grepping through its source, I got this:
- First, download the Windows installer and source
Then try this on Python command line:
from reportlab.pdfgen import canvas from reportlab.lib.units import inch, cm c = canvas.Canvas('ex.pdf') c.drawImage('ar.jpg', 0, 0, 10*cm, 10*cm) c.showPage() c.save()
All I needed is to get a bunch of images into a PDF, so that I can check how they look and print them. The above is sufficient to achieve that goal.
ReportLab is great, but would benefit from including helloworlds like the above prominently in its documentation.
Answer from Evgeni Sergeev on Stack OverflowHow to create PDF files in Python - Stack Overflow
What would be the best way to create a .pdf file with python?
Markdown to PDF renderer
Is it possible to generate LaTeX pdfs directly from python?
Why not get MiKTeX or a similar program that you can run locally? Then you can build the .tex file in python and typeset as part of your program. As a bonus you can clean up the .aux files if you want
More on reddit.comHow do I generate a PDF report from HTML in Python?
Use WeasyPrint for print-oriented HTML and CSS, or Playwright with Chromium when the report needs JavaScript. Nutrient API provides hosted HTML-to-PDF conversion with custom fonts, headers, footers, and page numbers.