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 Print a Pyramid Asterisk Pattern in Python? williamclark 0 778 Mar-24-2025, 10:05 AM
Last Post: williamclark
Smile Print Mystery Rchrd 3 1,223 Nov-10-2024, 01:51 AM
Last Post: Rchrd
  print/save on pdf starwhale 3 849 Nov-08-2024, 10:59 PM
Last Post: Gribouillis
  print in shell: b ??? trix 18 2,931 Aug-30-2024, 04:36 PM
Last Post: trix
  Print text with big font and style tomtom 6 20,438 Aug-13-2024, 07:26 AM
Last Post: yazistilleriio
  XML minidom "Pretty Print" Lost Data marksy95 2 1,164 Jun-15-2024, 11:09 AM
Last Post: Larz60+
  Print the next 3 lines knob 3 1,098 May-22-2024, 12:26 PM
Last Post: andraee
  Cannot get cmd to print Python file Schauster 11 3,030 May-16-2024, 04:40 PM
Last Post: xMaxrayx
  Odd Print Behavior tanner_1011 3 928 May-07-2024, 06:46 PM
Last Post: deanhystad
  How can I print from within actor(func) ?? Pedroski55 2 901 May-01-2024, 05:35 AM
Last Post: Pedroski55

Forum Jump:

User Panel Messages

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