Crisis Communication Template Generator

Crisis Communication Template Generator

Draft official statements for critical incidents.

Media Inquiries: All media inquiries should be directed to ${data.mediaContact}.

`; elements.outputContainer.innerHTML = templateHTML; }; const handleDownloadPdf = () => { const { jsPDF } = window.jspdf; if (!jsPDF) { console.error("jsPDF is not loaded."); return; } const data = getFormData(); const doc = new jsPDF({ orientation: 'portrait', unit: 'in', format: 'letter' }); const margin = 1; const pageWidth = doc.internal.pageSize.getWidth(); const pageHeight = doc.internal.pageSize.getHeight(); const usableWidth = pageWidth - (margin * 2); let currentY = margin; // --- PDF Header --- doc.setFont('helvetica', 'bold'); doc.setFontSize(10); doc.setTextColor('#DC2626'); // red-600 doc.text('OFFICIAL CRISIS COMMUNICATION', margin, currentY); doc.setFont('helvetica', 'normal'); doc.setTextColor('#374151'); // gray-700 doc.text(data.incidentDate, pageWidth - margin, currentY, { align: 'right' }); currentY += 0.2; doc.setLineWidth(0.02); doc.setDrawColor('#F59E0B'); // amber-500 doc.line(margin, currentY, pageWidth - margin, currentY); currentY += 0.4; // --- Title --- doc.setFont('times', 'bold'); doc.setFontSize(16); const title = `Statement on ${data.crisisType}`; const titleLines = doc.splitTextToSize(title, usableWidth); doc.text(titleLines, margin, currentY); currentY += (titleLines.length * 0.25) + 0.2; // --- Body Text --- doc.setFont('times', 'normal'); doc.setFontSize(12); doc.setTextColor('#000000'); // Function to add text block with heading const addTextBlock = (heading, text) => { if (currentY > pageHeight - margin) { doc.addPage(); currentY = margin; } doc.setFont('helvetica', 'bold'); doc.text(heading, margin, currentY); currentY += 0.25; doc.setFont('times', 'normal'); const textLines = doc.splitTextToSize(text, usableWidth); doc.text(textLines, margin, currentY); currentY += (textLines.length * 0.2) + 0.2; }; addTextBlock('Incident Summary:', data.incidentSummary); addTextBlock('Immediate Actions Taken:', data.actionsTaken); const commitmentText = "We are committed to transparency and will provide further updates as more information becomes available. Our team is working diligently to resolve this issue and support all affected parties."; addTextBlock('Our Commitment:', commitmentText); // --- Footer / Contact Info --- currentY = pageHeight - margin - 0.7; doc.setLineWidth(0.01); doc.setDrawColor('#6B7280'); // gray-500 doc.line(margin, currentY, pageWidth - margin, currentY); currentY += 0.2; doc.setFont('helvetica', 'bold'); doc.setFontSize(9); doc.text('Spokesperson:', margin, currentY); doc.setFont('helvetica', 'normal'); doc.text(data.spokesperson, margin + 1, currentY); currentY += 0.18; doc.setFont('helvetica', 'bold'); doc.text('Media Inquiries:', margin, currentY); doc.setFont('helvetica', 'normal'); doc.text(data.mediaContact, margin + 1, currentY); doc.save('Crisis-Communication-Statement.pdf'); }; // --- Event Listeners --- elements.tabDetails.addEventListener('click', () => switchTab('details')); elements.tabPreview.addEventListener('click', () => switchTab('preview')); elements.nextBtn.addEventListener('click', () => currentTab === 'details' && switchTab('preview')); elements.prevBtn.addEventListener('click', () => currentTab === 'preview' && switchTab('details')); elements.downloadPdfBtn.addEventListener('click', handleDownloadPdf); });
Scroll to Top