Python Forum
Problem with print variable in print.cell (fpdf)
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Problem with print variable in print.cell (fpdf)
#1
Hi, i have problem with printing result from some simple example in pdf file?
pdf.cell(200, 10, "Nesto stampam" + c_string, 1, 0)

import sys
import fpdf

from PyQt6 import QtWidgets, uic
from fpdf import FPDF

qtcreator_file  = "testna_forma.ui" # Enter file here.
Ui_Prozor, QtBaseClass = uic.loadUiType(qtcreator_file)


class MyApp(QtWidgets.QDialog, Ui_Prozor):
    def __init__(self):
        QtWidgets.QMainWindow.__init__(self)
        Ui_Prozor.__init__(self)
        self.setupUi(self)

        self.Izracunaj_dugme.clicked.connect(self.Izracunaj_sve)
        self.Stampaj_pdf.clicked.connect(self.Stampaj)

    def Izracunaj_sve(self):
           
           a = float(self.unesi_a.text())
           b = float(self.unesi_b.text())

           c = a + b
           d = a - b
           e = a * b
           f = a / b
            
           self.prikazi_c.setText(format(c))
           self.prikazi_d.setText(format(d))
           self.prikazi_e.setText(format(e))
           self.prikazi_f.setText(format(f))
           print(c)
           print(d)
           print(e)
           print(f)
           c_string = str(c)
           d_string = str(d)
           e_string = str(e)
           f_string = str(f)

    def Stampaj(self):

           pdf = FPDF('P', 'mm', 'A4')
           pdf.add_page()
           pdf.set_font('Arial', 'B', 12)
           pdf.cell(200, 10, "Nesto stampam" + c_string, 1, 0)
           #pdf.write(5,'Nesto stampam')
           pdf.output("Izvjestaj.pdf", 'F')

if __name__ == "__main__":
    app = QtWidgets.QApplication(sys.argv)
    window = MyApp()
    window.show()
    sys.exit(app.exec())
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How to Randomly Print a Quote From a Text File When User Types a Command on Main Menu BillKochman 13 912 Apr-24-2024, 05:47 AM
Last Post: Bronjer
  print doesnt work in a function ony 2 314 Mar-11-2024, 12:42 PM
Last Post: Pedroski55
  print(0.1+0.2==0.3) akbarza 3 414 Mar-04-2024, 02:02 PM
Last Post: Gribouillis
  problem with print command in super() akbarza 5 605 Feb-01-2024, 12:25 PM
Last Post: deanhystad
  problem with spliting line in print akbarza 3 405 Jan-23-2024, 04:11 PM
Last Post: deanhystad
  problem with print lists MarekGwozdz 4 696 Dec-15-2023, 09:13 AM
Last Post: Pedroski55
  dynamic variable name declaration in OOP style project problem jacksfrustration 3 798 Oct-22-2023, 10:05 PM
Last Post: deanhystad
  What a difference print() makes Mark17 2 580 Oct-20-2023, 10:24 PM
Last Post: DeaD_EyE
  elif not responding on print EddieG 3 876 Jul-20-2023, 09:44 PM
Last Post: Pedroski55
  print(data) is suddenly invalid syntax db042190 6 1,214 Jun-14-2023, 02:55 PM
Last Post: deanhystad

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020