Post-Purchase Engagement Messenger
Craft the perfect follow-up message to delight your customers.
Subject: ${generatedMessage.subject}
${generatedMessage.body}
`;
};
// --- PDF Download Logic ---
downloadPdfBtn.addEventListener('click', () => {
if (!window.jspdf) return;
generatePreview(); // Ensure data is current
const { jsPDF } = window.jspdf;
const doc = new jsPDF({ orientation: 'p', unit: 'pt', format: 'letter' });
const page = { width: doc.internal.pageSize.getWidth(), margin: 72 };
const contentWidth = page.width - page.margin * 2;
let y = page.margin;
doc.setFont('times', 'bold');
doc.setFontSize(14);
doc.text(`Subject: ${generatedMessage.subject}`, page.margin, y);
y += 30;
doc.setLineWidth(0.5);
doc.line(page.margin, y, page.width - page.margin, y);
y += 20;
doc.setFont('times', 'normal');
doc.setFontSize(12);
const textLines = doc.splitTextToSize(generatedMessage.body, contentWidth);
doc.text(textLines, page.margin, y, { lineHeightFactor: 1.5 });
doc.save(`Post-Purchase-Message-${document.getElementById('messageType').value}.pdf`);
});
// --- Initial Setup ---
switchTab('setup');
});
