Corrections
${correctionsCount}
Characters
${corrected.length}
`;
};
const showError = (message) => {
errorSection.textContent = message;
errorSection.style.display = 'block';
};
// --- 5. PDF Generation ---
pdfDownloadButton.addEventListener('click', () => {
if (!correctedTextForPdf) return;
const { jsPDF } = window.jspdf;
const doc = new jsPDF();
doc.setFontSize(18);
doc.text("Grammar & Punctuation Check Report", 105, 20, { align: 'center' });
doc.setFontSize(11);
doc.setTextColor(100);
doc.text(`Report Generated: ${new Date().toLocaleString('en-US')}`, 105, 28, { align: 'center' });
// Add Original Text
doc.setFontSize(14);
doc.setTextColor(0);
doc.text("Original Text", 14, 45);
doc.setFontSize(11);
const originalLines = doc.splitTextToSize(originalTextForPdf, 180);
doc.text(originalLines, 14, 52);
const finalY = doc.autoTable.previous.finalY || (52 + originalLines.length * 5);
// Add Corrected Text
doc.setFontSize(14);
doc.text("Corrected Text", 14, finalY + 15);
doc.setFontSize(11);
const correctedLines = doc.splitTextToSize(correctedTextForPdf, 180);
doc.text(correctedLines, 14, finalY + 22);
doc.save('Corrected_Text_Report.pdf');
});
});