简体   繁体   中英

python fpdf add an image in cell

I am generating a PDF file using FPDF in Python. Below is a code snippet, where I am creating a table using cell. The table consists of 3 columns. In the last cell of each row, I need to insert an image with a QR code. I don't know how to insert an image inside a cell.

#Create table header
height = 5
pdf.cell(w = 50, h = height, txt = 'Product', align = 'L', border = 'B', ln = 0)
pdf.cell(w = 120, h = height, txt = 'Instructioon', align = 'L', border = 'B', ln = 0)
pdf.cell(w = 20, h = height, txt = 'Video', align = 'L', border = 'B', ln = 1)
#Create the content in the first table row
pdf.cell(w = 50, h = height, txt = 'Product 1', align = 'L', ln = 0)
pdf.cell(w = 120, h = height, txt = 'some product descriptions', align = 'L', ln = 0)
#This is the cell I need to insert an image with a QR code, but I don't know how to insert the image inside a cell
pdf.cell(....)

Here is a workaround. Instead of creating the PDF directly with FPDF with limited functionality, you can create an HTML file, populate it with data, take a screen shot, and finally create a PDF.

See this Medium Article for reference: https://betterprogramming.pub/generating-stunning-pdf-reports-with-aws-and-python-a47274afe03d

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM