From e68e8a7003ef98d942004e6d9d4a947a68294fdc Mon Sep 17 00:00:00 2001 From: Marco Pedone Date: Tue, 3 Feb 2026 11:34:05 +0100 Subject: [PATCH] feat: update PDF generation to download file directly and rename button --- .../src/components/schedaAnnuncioStampabile.tsx | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/apps/infoalloggi/src/components/schedaAnnuncioStampabile.tsx b/apps/infoalloggi/src/components/schedaAnnuncioStampabile.tsx index c4feba2..0af547f 100644 --- a/apps/infoalloggi/src/components/schedaAnnuncioStampabile.tsx +++ b/apps/infoalloggi/src/components/schedaAnnuncioStampabile.tsx @@ -111,11 +111,17 @@ export function SchedaAnnuncioStampabile({ data }: { data: Annunci }) { ); } const blob = await response.blob(); - const url = window.URL.createObjectURL(blob); toast.success("PDF generato con successo!", { id: "generate-pdf", }); - window.open(url, "_blank"); + const url = window.URL.createObjectURL(blob); + const link = document.createElement("a"); + link.href = url; + link.download = `scheda-annuncio-${data.codice}.pdf`; + document.body.appendChild(link); + link.click(); + link.remove(); + window.URL.revokeObjectURL(url); } catch (error) { toast.error( `Errore durante la generazione del PDF: ${(error as Error).message}`, @@ -133,7 +139,7 @@ export function SchedaAnnuncioStampabile({ data }: { data: Annunci }) {

Scheda Annuncio Stampabile

- +