]> wagnertech.de Git - SVBaL.git/blobdiff - python/eh_util/eh_app/AWK/routines.py
pydev-s6git
[SVBaL.git] / python / eh_util / eh_app / AWK / routines.py
index 76a2c9642d99a8bdea536eb55e97e1df4a6317c8..f176462f27db85f3a48fb1b256d59f4027e2b55c 100644 (file)
@@ -23,4 +23,55 @@ def aktualisiere_config(config, data):
         
     if data["zusatzbeitrag"]:
         config.set_config("beitrag_zusatz", data["zusatzbeitrag"])
-        
\ No newline at end of file
+
+def erstelle_ehmeldung(data):
+    from PyPDF2 import PdfFileWriter, PdfFileReader
+    from datetime import date
+    import io
+    from reportlab.pdfgen import canvas
+    from reportlab.lib.pagesizes import letter
+    
+    packet = io.BytesIO()
+    can = canvas.Canvas(packet, pagesize=letter)
+    
+    # Adressfeld
+    can.setFont("Helvetica", 12)
+    can.drawString(205, 618, data["VorZuname"])
+    can.drawString(205, 600, data["VorZunamePartner"])
+    can.drawString(205, 583, data["Wohnanschrift"])
+    can.drawString(205, 566, data["Telefon"])
+    can.drawString(365, 566, data["Email"])
+    can.drawString(205, 549, data["Geburtsdatum"])
+    versichertes_object = data["VersichertesObjekt"]
+    if versichertes_object == "":
+        versichertes_object = data["Wohnanschrift"]
+    can.drawString(205, 500, versichertes_object)
+    can.drawString(193, 466, str(data["AnzahlWohnungen"]))
+    if data["Selbstgenutzt"]:
+        can.drawString(350, 466, "X")
+    if data["Eigentumswohnung"]:
+        can.drawString(188, 449, "X")
+    if data["Gewerblich"]:
+        can.drawString(350, 449, "X")
+    can.drawString(140, 376, date.today().strftime('%d.%m.%Y'))
+    can.drawString(350, 376, "Maschinell erstellt.")
+        
+    can.save()
+    
+    #move to the beginning of the StringIO buffer
+    packet.seek(0)
+    
+    # create a new PDF with Reportlab
+    new_pdf = PdfFileReader(packet)
+    # read your existing PDF
+    existing_pdf = PdfFileReader(open("/home/sparky2021/SVBaL/Aktuell/BeitrittserklarungSVBaL.pdf", "rb"))
+    output = PdfFileWriter()
+    # add the "watermark" (which is the new pdf) on the existing page
+    page = existing_pdf.pages[0]
+    page.mergePage(new_pdf.pages[0])
+    output.addPage(page)
+    # finally, write "output" to a real file
+    output_stream = open("meldung.pdf", "wb")
+    output.write(output_stream)
+    output_stream.close()
+      
\ No newline at end of file