I want to transform images to pdf. I think fpdf
is the best package.
The version is the latest FPDF 1.7.2
. Python version 3.7.2
64 bit.
from fpdf import FPDF
pdf = FPDF()
pdf.add_page()
pdf.image(r'C:\Users\Bin\Desktop\a\tt.jpg')
An error happened:
RuntimeError: FPDF error: Missing or incorrect image file:
C:\Users\Bin\Desktop\a\tt.jpg. error: No JPEG marker found
The file directory is correct. When I transform the file to a png
, then it works. It does not work with any other file format such jpeg/jpg
.How to solve it?
This problem Python images to pdf has appeared in stackoverflow. However, all of them does not work for me.