Corporate Announcement Copy Generator

Corporate Announcement Copy Generator

Craft professional announcements with ease.

${body.replace(/\n/g, '
')}

`; currentTab = tabs.length - 1; showTab(currentTab); }; const downloadPDF = () => { const { jsPDF } = window.jspdf; const doc = new jsPDF({ unit: 'pt', format: 'a4' }); const filename = `${generatedCopy.headline.replace(/\s+/g, '-')}.pdf`; const pageHeight = doc.internal.pageSize.height; const pageWidth = doc.internal.pageSize.width; const margin = 70; const contentWidth = pageWidth - margin * 2; let cursorY = margin; // --- PDF Template: Corporate Memo --- doc.setFont('helvetica', 'bold'); doc.setFontSize(16); doc.setTextColor(17, 24, 39); // Gray 900 doc.text("INTERNAL MEMORANDUM", margin, cursorY); cursorY += 40; const today = new Date().toLocaleDateString('en-US', { year: 'numeric', month: 'long', day: 'numeric'}); const headerInfo = [ { label: 'TO:', value: 'All Staff' }, { label: 'FROM:', value: 'Management' }, { label: 'DATE:', value: today }, { label: 'SUBJECT:', value: generatedCopy.headline || 'Company Announcement' } ]; doc.setFont('helvetica', 'bold'); doc.setFontSize(10); headerInfo.forEach(item => { if (cursorY > pageHeight - margin) { doc.addPage(); cursorY = margin; } doc.text(item.label, margin, cursorY); doc.setFont('helvetica', 'normal'); const valueLines = doc.splitTextToSize(item.value, contentWidth - 50); doc.text(valueLines, margin + 60, cursorY); cursorY += (valueLines.length * 12) + 6; }); cursorY += 10; doc.setDrawColor(229, 231, 235); // Gray 200 doc.setLineWidth(1.5); doc.line(margin, cursorY, pageWidth - margin, cursorY); cursorY += 30; doc.setFont('times', 'normal'); doc.setFontSize(12); doc.setTextColor(55, 65, 81); // Gray 600 const bodyLines = doc.splitTextToSize(generatedCopy.body, contentWidth); doc.text(bodyLines, margin, cursorY); doc.save(filename); }; // --- Event Handling --- announcementTypeSelect.addEventListener('change', updateDetailsFields); nextButton.addEventListener('click', () => { if (currentTab < tabs.length - 2) { currentTab++; showTab(currentTab); } }); prevButton.addEventListener('click', () => { if (currentTab > 0) { currentTab--; showTab(currentTab); } }); generateButton.addEventListener('click', generateCopy); downloadPdfButton.addEventListener('click', downloadPDF); tabs.forEach(tab => { tab.addEventListener('click', () => { const tabIndex = parseInt(tab.dataset.tab, 10); if (tabIndex === tabs.length - 1 && !generatedCopy.headline) { generateCopy(); } else { currentTab = tabIndex; showTab(currentTab); } }); }); // --- Initialization --- showTab(0); updateDetailsFields(); });
Scroll to Top