diff --git a/cemento.py b/cemento.py index cb1d7b5..884698d 100644 --- a/cemento.py +++ b/cemento.py @@ -49,31 +49,28 @@ def index(): msg_stampa = None if request.method == 'POST': res = calcola(request.form) - # Se รจ stato premuto il tasto stampa, esegui la logica Docker if 'btn_stampa' in request.form: - msg_stampa = esegui_stampa_cups(request.form) + msg_stampa = esegui_stampa_pdf(request.form) return render_template('index.html', res=res, form=request.form, msg_stampa=msg_stampa) -def esegui_stampa_cups(f): +def esegui_stampa_pdf(f): try: - # PostScript arricchito con tutti i dati ps_content = f"""%!PS /Helvetica-Bold findfont 18 scalefont setfont 100 750 moveto (REPORT TECNICO CALCOLO CEMENTO) show /Helvetica findfont 12 scalefont setfont 100 720 moveto (Volume Totale: {f.get('res_vol')} m3 | Peso: {f.get('res_peso')} Kg) show -100 700 moveto (Costo Complessivo: {f.get('res_costo_t')} Euro) show -100 670 moveto (ACQUISTI:) show -120 655 moveto (- Cemento: {f.get('res_s_cem')} sacch.) show -120 640 moveto (- Sabbia: {f.get('res_s_sab')} sacch.) show -120 625 moveto (- Ghiaia: {f.get('res_s_ghi')} sacch.) show -120 610 moveto (- Acqua: {f.get('res_aq')} L) show -100 580 moveto (CARICO BETONIERA ({f.get('res_nc')} carichi):) show -120 565 moveto (- Cemento: {f.get('res_bc_cem')} pezzi) show -120 550 moveto (- Sabbia: {f.get('res_bc_sab')} pezzi) show -120 535 moveto (- Ghiaia: {f.get('res_bc_ghi')} pezzi) show -120 520 moveto (- Acqua: {f.get('res_bc_aq')} L) show -100 480 moveto (Data: 20/01/2026) show +100 705 moveto (Costo Totale: {f.get('res_costo_t')} Euro | Acqua: {f.get('res_aq')} L) show +100 680 moveto (DETTAGLIO ACQUISTI:) show +120 665 moveto (- Cemento: {f.get('res_s_cem')} sacch.) show +120 650 moveto (- Sabbia: {f.get('res_s_sab')} sacch.) show +120 635 moveto (- Ghiaia: {f.get('res_s_ghi')} sacch.) show +100 605 moveto (CARICO BETONIERA ({f.get('res_nc')} carichi):) show +120 590 moveto (- Cemento: {f.get('res_bc_cem')} sacch.) show +120 575 moveto (- Sabbia: {f.get('res_bc_sab')} sacch.) show +120 560 moveto (- Ghiaia: {f.get('res_bc_ghi')} sacch.) show +120 545 moveto (- Acqua: {f.get('res_bc_aq')} L) show +100 500 moveto (Software Cemento Rev.1 | Data: 20/01/2026) show showpage""" comando = ["docker", "exec", "-i", "cups-pdf-server", "lp", "-d", "Virtual_PDF"] subprocess.run(comando, input=ps_content.encode('utf-8'), capture_output=True)