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 }) {