PyFPDF is a library for PDF document generation under Python, ported from PHP (see FPDF: "Free"-PDF, a well-known PDFlib-extension replacement.
Questions tagged [pyfpdf]
90 questions
1
vote
1 answer
pyFPDF .add_page() function breaking when instantiating from classmethod
The add_page() function errors whenever I try to get any user input in __init__() or a classmethod. It works fine when I don't have any methods to get user input, so I think it's somehow interfering.
AttributeError: 'PDF' object has no attribute…
user19417852
1
vote
1 answer
Save Matplotlib subplot as PDF using PyFPDF
I am trying to create two figures with two plots in each figure and then create a PDF file with one of the figures. I want to choose which figure will be saved in the PDF file.
I have this simple code. It's just an example:
from fpdf import…

Tiago
- 15
- 4
1
vote
0 answers
add_page() not accepting the parameters for width and height of the page in FPDF
I was converting a number of images to pdf using FPDF in python, however doing:
pdf.add_page('P',x,y)
(x and y are well defined and have values, pdf = FPDF())
Returns the following error:
Traceback (most recent call last):
File…

Wizard
- 11
- 3
1
vote
0 answers
Output not doing anything when using PyFPDF
I'm trying to put all the images in a directory into a single PDF. I'm writing in python 3 and using PyFPDF. This is my code:
import os
from fpdf import FPDF
pdf = FPDF()
list = os.listdir(r'C:\this\is\my\destination\library')
count = 1
for name in…

Luc Wiegers
- 25
- 4
1
vote
3 answers
ModuleNotFoundError: No module named 'fpdf'
Getting this error: ModuleNotFoundError: No module named 'fpdf'
I've re-downloaded python, created a new venv and installed fpdf2 using pip install fpdf2, but I still get this error when I run from fpdf import FPDF
python version: 3.10.4
I've looked…

Griffin Bell
- 61
- 1
- 4
1
vote
0 answers
How to have an auto page break for pyfpdf when the image exceeds the page dimensions?
I looked at a similar question here but there doesn't seem to be a solution except to switch to a different library.
I have created some code to automatically space my images vertically and horizontally, but I am having a problem with auto page…

Pherdindy
- 1,168
- 7
- 23
- 52
1
vote
0 answers
How to set language in PyFPDF to enable Adobe to read aloud correctly?
I have a python app that generate PDF documents in the Swedish language. However, the read-aloud function in Adobe think it's English so the result is incomprehensible. When I check the document properties for my PDF there is no language predefined,…

Henri
- 1,077
- 10
- 24
1
vote
1 answer
Drawing lines on PDF with Python
Is there a way to draw lines on a PDF file, by giving it coordinates of the start and end points? I have tried PyFPDF but cannot find much documentation about implementing it.

user840
- 134
- 1
- 13
1
vote
1 answer
How to solve line discontinuity in html table (python fpdf2 generate PDF documents)
I try to generate a PDF document. I use PYPDF2. The PDF contains a table which is generated by :
class HTMLMixin:
HTML2FPDF_CLASS = HTML2FPDF
def write_html(self, text, *args, **kwargs):
"""Parse HTML and convert it to PDF"""
…

Sanyifejű
- 2,610
- 10
- 46
- 73
1
vote
1 answer
Python3 fpdf is giving me an error latin-1 codec can't encode character
When I run the code below I get the following traceback:
Traceback (most recent call last):
File "C:\demo\test.py", line 11, in
pdf.output("splintered.pdf")
File "C:\demo\lib\site-packages\fpdf\fpdf.py", line 1065, in output
…

Silver Wolf2r
- 64
- 6
1
vote
0 answers
Line spacing is extremely large in pyfpdf multicell
I met this issue.
When I used multi-cell to output multiple lines of texts in a cell, the line spacing in the cell is extremely large.
I cannot find the possible function or parameters to tune and is there any buddy to solve this kind of issue?

KCHAN
- 11
- 1
1
vote
1 answer
FPDF2 Python : How to calculate the multicell height after a long string inside?
I am having an issue calculating the correct height of a multicell in FPDF. I am running into issues of overlapping when using pdf.ln() as the content in the cell is overflowing. What can I do to dynamically solve this for any length of the…

Derik002
- 145
- 13
1
vote
0 answers
Python merge pdf's together with hyperlinks
I am trying to merge two pdf's together. The other pdf is table of contents that I create manually using fpdf that links to specific pages. The other pdf is the text where the table of content links to.
from PyPDF2.merger imort…

MesRot
- 133
- 1
- 9
1
vote
0 answers
PyFPDF produces vertical text
Some time ago, I translated a PHP script to python, but I am getting a few problems more recently. (it's a script to generate voting ballots)
The code:
The full code is here: https://pastebin.com/ULAF1Nh5
The part that prints the voting options (the…

Julio974
- 77
- 1
- 2
- 7
1
vote
0 answers
Python maplotlib PNG and FPDF
I have a Python program that creates a lot of plots with matplotlib. These images are then compiled into a PDF report using Python fpdf module.
The problem is, with PNGs produced with matplotlib, this is extremely slow. Each image takes…

mpjohnso
- 11
- 2