Reading & Proofreading Tool Reading & Proofreading Tool Generate comprehension quizzes or proofread your text. Comprehension Quiz Quiz Results Proofreading Assistant Enter Text Passage Generate Quiz Generating... Quiz Results Your results will be displayed here after you complete the quiz. Download Quiz Results as PDF Enter Text to Proofread Proofread Text Proofreading... Download Analysis as PDF No errors found!'} `; proofreadResultContainer.innerHTML = resultsHtml; proofreadPdfDownloadBtn.classList.remove('hidden'); }; // --- PDF Download Functions --- const downloadPDF = async (elementId, fileName) => { const { jsPDF } = window.jspdf; const pdfOutput = document.getElementById(elementId); if (!pdfOutput) return; const canvas = await html2canvas(pdfOutput, { scale: 2, backgroundColor: '#ffffff' }); const imgData = canvas.toDataURL('image/png'); const pdf = new jsPDF({ orientation: 'portrait', unit: 'pt', format: 'a4' }); const pdfWidth = pdf.internal.pageSize.getWidth(); const imgProps = pdf.getImageProperties(imgData); const pdfHeight = (imgProps.height * pdfWidth) / imgProps.width; pdf.addImage(imgData, 'PNG', 40, 40, pdfWidth - 80, pdfHeight - 80); pdf.save(fileName); }; // --- Event Listeners --- generateQuizBtn.addEventListener('click', handleQuizGeneration); quizPdfDownloadBtn.addEventListener('click', () => downloadPDF('quizPdfOutput', 'Quiz-Results.pdf')); proofreadBtn.addEventListener('click', handleProofread); proofreadPdfDownloadBtn.addEventListener('click', () => downloadPDF('proofreadPdfOutput', 'Proofreading-Analysis.pdf')); // Initialize view showTab('quizTab'); });