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):
12 if data["briefpapier"]:
13 uploaded_file = data["briefpapier"]
14 data_path = config.requireConfig("data_path")
15 # copy briefpapier into data_path
16 with open(os.path.join(data_path, uploaded_file.name), 'wb+') as destination:
17 for chunk in uploaded_file.chunks():
18 destination.write(chunk)
19 config.set_config("briefpapier", uploaded_file.name)
21 if data["basisbeitrag"]:
22 config.set_config("beitrag_basis", data["basisbeitrag"])
24 if data["zusatzbeitrag"]:
25 config.set_config("beitrag_zusatz", data["zusatzbeitrag"])
27 def erstellepdf(text):
28 with open(r'G:\SVBaL\python\eh_util\eh_app\test.tex', 'w') as f: # öffnet ein neues Dokument mit dem Namen test.tex
29 f.write(text) # schreibt in dieses neue Dokument
31 # TODO: AUfruf PDF latex tex -> pdf
33 def erstelle_ehmeldung(data):
34 from PyPDF2 import PdfFileWriter, PdfFileReader
35 from datetime import date
37 from reportlab.pdfgen import canvas
38 from reportlab.lib.pagesizes import letter
41 can = canvas.Canvas(packet, pagesize=letter)
44 can.setFont("Helvetica", 12)
45 can.drawString(205, 618, data["VorZuname"])
46 can.drawString(205, 600, data["VorZunamePartner"])
47 can.drawString(205, 583, data["Wohnanschrift"])
48 can.drawString(205, 566, data["Telefon"])
49 can.drawString(365, 566, data["Email"])
50 can.drawString(205, 549, data["Geburtsdatum"])
51 versichertes_object = data["VersichertesObjekt"]
52 if versichertes_object == "":
53 versichertes_object = data["Wohnanschrift"]
54 can.drawString(205, 500, versichertes_object)
55 can.drawString(193, 466, str(data["AnzahlWohnungen"]))
56 if data["Selbstgenutzt"]:
57 can.drawString(350, 466, "X")
58 if data["Eigentumswohnung"]:
59 can.drawString(188, 449, "X")
60 if data["Gewerblich"]:
61 can.drawString(350, 449, "X")
62 can.drawString(140, 376, date.today().strftime('%d.%m.%Y'))
63 can.drawString(350, 376, "Maschinell erstellt.")
67 #move to the beginning of the StringIO buffer
70 # create a new PDF with Reportlab
71 new_pdf = PdfFileReader(packet)
72 # read your existing PDF
73 existing_pdf = PdfFileReader(open("/home/sparky2021/SVBaL/Aktuell/BeitrittserklarungSVBaL.pdf", "rb"))
74 output = PdfFileWriter()
75 # add the "watermark" (which is the new pdf) on the existing page
76 page = existing_pdf.pages[0]
77 page.mergePage(new_pdf.pages[0])
79 # finally, write "output" to a real file
80 output_stream = open("meldung.pdf", "wb")
81 output.write(output_stream)