Gratitude Journal Generator
Find new reasons to be thankful every day.
This tool is for personal inspiration. If you are struggling with your mental health, please seek help from a qualified professional.
Sorry, we couldn\'t generate prompts right now. Please try again in a moment.
'; } finally { elements.loadingSpinner.classList.add('hidden'); } } async function downloadPDF() { const { jsPDF } = window.jspdf; const pdf = new jsPDF({ orientation: 'p', unit: 'mm', format: 'a4' }); const contentArea = elements.pdfContentArea; if (!contentArea) { console.error("PDF content area not found!"); return; } document.body.classList.add('pdf-export-mode'); try { const canvas = await html2canvas(contentArea, { scale: 2, useCORS: true, logging: false, backgroundColor: '#FEFCE8' // Match the journal page background }); document.body.classList.remove('pdf-export-mode'); const imgData = canvas.toDataURL('image/png'); const imgProps = pdf.getImageProperties(imgData); const pdfWidth = pdf.internal.pageSize.getWidth() - 20; // A4 width with margin const pdfHeight = (imgProps.height * pdfWidth) / imgProps.width; pdf.addImage(imgData, 'PNG', 10, 10, pdfWidth, pdfHeight); const dateForFilename = new Date().toISOString().split('T')[0]; pdf.save(`Gratitude_Journal_${dateForFilename}.pdf`); } catch (error) { console.error("Error generating PDF:", error); document.body.classList.remove('pdf-export-mode'); alert("An error occurred while generating the PDF. Please try again."); } } // --- INITIALIZATION --- // Generate prompts on initial page load generatePrompts(); });