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 7,272 Dec-16-2025, 05:29 PM
Last Post: zodazy
  No new line from print in a browser Lou 13 1,365 Dec-01-2025, 06:39 PM
Last Post: noisefloor
  [split] print two different sequence number Reema 1 686 Nov-10-2025, 05:37 AM
Last Post: Gribouillis
  print does not open console in Linux Mint [Solved] Tycho_2025 5 804 Oct-04-2025, 08:52 AM
Last Post: Tycho_2025
  How to Print a Pyramid Asterisk Pattern in Python? williamclark 0 1,572 Mar-24-2025, 10:05 AM
Last Post: williamclark
Smile Print Mystery Rchrd 3 1,864 Nov-10-2024, 01:51 AM
Last Post: Rchrd
  print/save on pdf starwhale 3 1,600 Nov-08-2024, 10:59 PM
Last Post: Gribouillis
  print in shell: b ??? trix 18 5,260 Aug-30-2024, 04:36 PM
Last Post: trix
  Print text with big font and style tomtom 6 24,347 Aug-13-2024, 07:26 AM
Last Post: yazistilleriio
  XML minidom "Pretty Print" Lost Data marksy95 2 2,097 Jun-15-2024, 11:09 AM
Last Post: Larz60+

Forum Jump:

User Panel Messages

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