Update cemento.py
This commit is contained in:
25
cemento.py
25
cemento.py
@@ -49,28 +49,23 @@ def index():
|
||||
msg_stampa = None
|
||||
if request.method == 'POST':
|
||||
res = calcola(request.form)
|
||||
if 'btn_stampa' in request.form:
|
||||
msg_stampa = esegui_stampa_pdf(request.form)
|
||||
if 'btn_stampa_cups' in request.form:
|
||||
msg_stampa = esegui_stampa_cups(request.form)
|
||||
return render_template('index.html', res=res, form=request.form, msg_stampa=msg_stampa)
|
||||
|
||||
def esegui_stampa_pdf(f):
|
||||
def esegui_stampa_cups(f):
|
||||
try:
|
||||
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 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
|
||||
100 720 moveto (Volume: {f.get('res_vol')} m3 | Peso: {f.get('res_peso')} Kg) show
|
||||
100 705 moveto (Costo: {f.get('res_costo_t')} Euro | Acqua: {f.get('res_aq')} L) show
|
||||
100 680 moveto (ACQUISTI:) show
|
||||
120 665 moveto (- Cemento: {f.get('res_s_cem')} | Sabbia: {f.get('res_s_sab')} | Ghiaia: {f.get('res_s_ghi')}) show
|
||||
100 640 moveto (CARICO BETONIERA ({f.get('res_nc')} carichi):) show
|
||||
120 625 moveto (- Cemento: {f.get('res_bc_cem')} | Sabbia: {f.get('res_bc_sab')} | Ghiaia: {f.get('res_bc_ghi')}) show
|
||||
100 550 moveto (Software Cemento Rev.1 | 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)
|
||||
|
||||
Reference in New Issue
Block a user