Bonjour,
en utilisant la séquence suivante :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
 
# save FPDF() class into 
# a variable pdf
pdf = FPDF()   
 
# Add a page
pdf.add_page()
 
# set style and size of font 
# that you want in the pdf
pdf.set_font("Arial", size = 15)
 
# open the text file in read mode
f = open(dir_init + nom, "r")
 
# insert the texts in pdf
for x in f:
    pdf.cell(200, 10, txt = x, ln = 1, align = 'L')
 
# save the pdf with name .pdf
pdf.output(dir_init + nom + ".pdf")
je récupère l'erreur suivante :
Traceback (most recent call last):
File "/home/jam/tess.py", line 21, in <module>
pdf.output(dir_init + nom + ".pdf")
File "/home/jam/.local/lib/python3.10/site-packages/fpdf/fpdf.py", line 1065, in output
self.close()
File "/home/jam/.local/lib/python3.10/site-packages/fpdf/fpdf.py", line 246, in close
self._enddoc()
File "/home/jam/.local/lib/python3.10/site-packages/fpdf/fpdf.py", line 1636, in _enddoc
self._putpages()
File "/home/jam/.local/lib/python3.10/site-packages/fpdf/fpdf.py", line 1170, in _putpages
p = self.pages[n].encode("latin1") if PY3K else self.pages[n]
UnicodeEncodeError: 'latin-1' codec can't encode character '\u2019' in position 685: ordinal not in range(256)
J'ai essayé plusieurs solutions, mais sans succès.

Merci pour votre aide