3 def handle_uploaded_file(csv_file):
4 csv_file_name = str(csv_file)
5 data_path = config.getInstance().requireConfig("data_path")
6 path = os.path.join(data_path, csv_file_name)
7 with open(path, 'wb+') as destination:
8 for chunk in csv_file.chunks():
9 destination.write(chunk)
11 def aktualisiere_config(config, data, file):
14 uploaded_file = file.name
15 data_path = config.requireConfig("data_path")
16 # copy briefpapier into data_path
17 with open(os.path.join(data_path, uploaded_file), 'wb+') as destination:
18 for chunk in file.chunks():
19 destination.write(chunk)
20 config.setConfig("briefpapier", uploaded_file)
22 if data["basisbeitrag"]:
23 config.setConfig("beitrag_basis", data["basisbeitrag"])
25 if data["zusatzbeitrag"]:
26 config.setConfig("beitrag_zusatz", data["zusatzbeitrag"])
28 def erstellepdf(text):
29 with open(r'G:\SVBaL\python\eh_util\eh_app\test.tex', 'w') as f: # öffnet ein neues Dokument mit dem Namen test.tex
30 f.write(text) # schreibt in dieses neue Dokument
32 # TODO: AUfruf PDF latex tex -> pdf
34 def erstelle_ehmeldung(data):
35 from PyPDF2 import PdfFileWriter, PdfFileReader
36 from datetime import date
38 from reportlab.pdfgen import canvas
39 from reportlab.lib.pagesizes import letter
42 can = canvas.Canvas(packet, pagesize=letter)
45 can.setFont("Helvetica", 14)
46 can.drawString(80, 770, "Siedlervereinigung Berg am Laim")
47 can.setFont("Helvetica", 12)
48 can.drawString(205, 618, data["VorZuname"])
49 can.drawString(205, 600, data["VorZunamePartner"])
50 can.drawString(205, 583, data["Wohnanschrift"])
51 can.drawString(205, 566, data["Telefon"])
52 can.drawString(365, 566, data["Email"])
53 can.drawString(205, 549, data["Geburtsdatum"])
54 versichertes_object = data["VersichertesObjekt"]
55 if versichertes_object == "":
56 versichertes_object = data["Wohnanschrift"]
57 can.drawString(205, 500, versichertes_object)
58 can.drawString(193, 466, str(data["AnzahlWohnungen"]))
59 if data["Selbstgenutzt"]:
60 can.drawString(360, 466, "X")
61 if data["Eigentumswohnung"]:
62 can.drawString(192, 449, "X")
63 if data["Gewerblich"]:
64 can.drawString(360, 449, "X")
65 can.drawString(140, 376, date.today().strftime('%d.%m.%Y'))
66 can.drawString(350, 376, "Maschinell erstellt.")
70 #move to the beginning of the StringIO buffer
73 # create a new PDF with Reportlab
74 new_pdf = PdfFileReader(packet)
75 # read your existing PDF
76 existing_pdf = PdfFileReader(open("/home/sparky2021/SVBaL/Aktuell/BeitrittserklarungSVBaL.pdf", "rb"))
77 output = PdfFileWriter()
78 # add the "watermark" (which is the new pdf) on the existing page
79 page = existing_pdf.pages[0]
80 page.mergePage(new_pdf.pages[0])
82 # finally, write "output" to a real file
83 output_stream = open("meldung.pdf", "wb")
84 output.write(output_stream)