Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any Python 3 module to create PDF files? [closed]

I have for some time looking for something to be able to create PDFs and integrate with my current project in Python 3. The usual references are Reportlab or pyPDF. But these two are not yet compatible with Python 3. I do see that since 2010 there has been some discussion about the port in Reportlab, but as of today I can't find any reference to the port.

Another alternative is to use an intermediate format from Python 3 to be consumed in another program, wrapped with a subprocess call. Relatorio does this. I might consider doing something similar or even generate XHTML/CSS and use xhtml2pdf.

like image 469
cyraxjoe Avatar asked Aug 18 '12 18:08

cyraxjoe


People also ask

How do you close a PDF in Python?

Python File close() Method Python file method close() closes the opened file. A closed file cannot be read or written any more.

Can Python create PDF file?

FPDF is a Python class that allows generating PDF files with Python code. It is free to use and it does not require any API keys. FPDF stands for Free PDF.

What is the best PDF library for Python?

The PDFQuery library is considered among the fastest Python scraping library. It acts as a light wrapper around pdfminer, pyquery, and lxml. It is designed in order to extract data reliably from sets of PDFs with as little code as possible.

How do I open a PDF in Python 3?

Popen() — Without CMD. If you want to open a PDF file in the standard PDF viewer such as Adobe Acrobat Reader, you can use the subprocess. Popen([path], shell=True) command. This doesn't open an intermediary command line prompt but opens the PDF directly in the viewer.


2 Answers

There is a new kid on the block which look promising. It supports print css features like page break.

Try weasyprint

like image 175
yvess Avatar answered Oct 19 '22 07:10

yvess


The cairo library with the pycairo (not py2cairo, that's for python 2) binding works with python 3.x and can produce PDF output (among others).

like image 45
Roland Smith Avatar answered Oct 19 '22 06:10

Roland Smith