Case Study Analysis Tool
Structure and formalize your case study findings.
This analysis is fully editable. Click the text to make changes before downloading.
[Add your summary of key takeaways and the overall conclusion here. What did this case study teach? What are the implications for future projects?]
`; analysisContainer.innerHTML = analysisHTML; downloadPdfBtn.classList.remove('hidden'); }; const downloadPdf = () => { const { jsPDF } = window.jspdf; const doc = new jsPDF({ orientation: 'p', unit: 'mm', format: 'a4' }); const content = getEl('generated-analysis-container'); const title = `Case Study: ${caseSubjectInput.value.trim()}`; const pageWidth = doc.internal.pageSize.getWidth(); const margin = 15; let yPos = 0; // --- PDF Template: Case Study Briefing --- doc.setFillColor(71, 85, 105); // Slate-600 doc.rect(0, 0, pageWidth, 28, 'F'); doc.setFont('helvetica', 'bold'); doc.setFontSize(16); doc.setTextColor(255, 255, 255); doc.text("CASE STUDY BRIEFING", margin, 18); yPos = 40; html2canvas(content, { scale: 2, useCORS: true }).then(canvas => { const imgData = canvas.toDataURL('image/png'); const imgProps = doc.getImageProperties(imgData); const pdfWidth = pageWidth - (margin * 2); const pdfHeight = (imgProps.height * pdfWidth) / imgProps.width; let heightLeft = pdfHeight; let position = yPos; doc.addImage(imgData, 'PNG', margin, position, pdfWidth, pdfHeight); heightLeft -= (doc.internal.pageSize.getHeight() - position - 15); while (heightLeft >= 0) { position = heightLeft - pdfHeight + 15; doc.addPage(); doc.addImage(imgData, 'PNG', margin, 15, pdfWidth, pdfHeight, undefined, 'FAST'); heightLeft -= doc.internal.pageSize.getHeight(); } // Footer const pageCount = doc.internal.getNumberOfPages(); for(let i = 1; i <= pageCount; i++) { doc.setPage(i); const footerY = doc.internal.pageSize.getHeight() - 15; doc.setFontSize(8); doc.setTextColor(100, 116, 139); doc.text(`Internal Analysis Document`, margin, footerY); doc.text(`Page ${i} of ${pageCount}`, pageWidth - margin, footerY, { align: 'right' }); } doc.save(`Case_Study_${caseSubjectInput.value.trim().replace(/\s/g, '_')}.pdf`); }).catch(err => { console.error("Error generating PDF:", err); alert("Could not generate PDF. See console for details."); }); }; const showTab = (tabNum) => { currentTab = tabNum; tabButtons.forEach(btn => btn.classList.toggle('active', parseInt(btn.dataset.tab) === tabNum)); tabPanes.forEach(pane => pane.classList.toggle('hidden', parseInt(pane.id.split('-')[2]) !== tabNum)); prevBtn.classList.toggle('invisible', currentTab === 1); nextBtn.textContent = currentTab === 1 ? 'Generate Analysis' : 'Generate Again'; }; // --- Event Listeners --- tabButtons.forEach(button => { button.addEventListener('click', () => { const tabNum = parseInt(button.dataset.tab); if (tabNum === 2 && currentTab === 1) generateAnalysis(); showTab(tabNum); }); }); prevBtn.addEventListener('click', () => { if (currentTab > 1) showTab(currentTab - 1) }); nextBtn.addEventListener('click', () => { if (currentTab === 1) { generateAnalysis(); showTab(2); } else { generateAnalysis(); } }); downloadPdfBtn.addEventListener('click', downloadPdf); // --- Initial Setup --- showTab(1); });