Home > Software engineering >  How to generate a pdf report with math/calculus results
How to generate a pdf report with math/calculus results

Time:06-07

I'm trying for the first time generate a pdf report with math results, and I'm asking for help here because I allready searched online and didn´t found anything relatable. I tried adpating a code that I found and I added the variable that I want to export to the pdf, in this case "C", however didn´t work out. Any idea?

Code:

from fpdf import FPDF 
pdf = FPDF() 

a = 1
b = 1
C = a b
   
pdf.add_page() 
  
pdf.set_font("Arial", size = 25) 
  
# create a cell 
pdf.cell(200, 10, txt = "a b =", C, 
        ln = 1, align = 'C') 
  
  
pdf.output("a.pdf")

CodePudding user response:

You are not concatenating correctly .. Python uses and you need to convert your integer to a string with str()

txt = "a b =" str(C),
  • Related