Dec-25-2022, 02:24 PM
Hi, i have problem with printing result from some simple example in pdf file?
pdf.cell(200, 10, "Nesto stampam" + c_string, 1, 0)
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())
