Grammar and Style Checker

Grammar & Style Checker

Improve your writing with AI-powered suggestions

Analysis Report

Suggestions will appear here.

Write some text and click "Check Text" to begin.

Writing Analysis Report

Original Text

Corrected Text

Suggestions

Type Original Suggestion Reason

Reason: ${item.explanation}

`; suggestionsList.appendChild(card); }); } // Store results on the element for PDF generation resultsContainer.dataset.analysis = JSON.stringify(analysis); resultsContainer.classList.remove('hidden'); downloadPdfBtn.disabled = false; lucide.createIcons(); } async function handlePdfDownload() { const analysisString = resultsContainer.dataset.analysis; if (!analysisString) { alert("No analysis data to download."); return; } const analysis = JSON.parse(analysisString); const pdfOriginal = document.getElementById('pdf-original-text'); const pdfCorrected = document.getElementById('pdf-corrected-text'); const pdfTableBody = document.querySelector('#pdf-suggestions-table tbody'); pdfOriginal.textContent = originalTextForPdf; pdfCorrected.textContent = analysis.correctedText; pdfTableBody.innerHTML = ''; if (analysis.suggestions.length > 0) { analysis.suggestions.forEach(item => { const row = ` ${item.type} ${item.original} ${item.suggestion} ${item.explanation} `; pdfTableBody.insertAdjacentHTML('beforeend', row); }); } else { pdfTableBody.innerHTML = 'No suggestions were made. The text was grammatically correct.'; } const contentToPrint = document.getElementById('pdf-output'); contentToPrint.style.display = 'block'; try { const canvas = await html2canvas(contentToPrint, { scale: 2 }); const { jsPDF } = window.jspdf; const imgData = canvas.toDataURL('image/png'); const pdf = new jsPDF({ orientation: 'portrait', unit: 'pt', format: 'a4' }); const pdfWidth = pdf.internal.pageSize.getWidth(); const pdfHeight = (canvas.height * pdfWidth) / canvas.width; pdf.addImage(imgData, 'PNG', 0, 0, pdfWidth, pdfHeight); pdf.save('Grammar-and-Style-Report.pdf'); } catch (err) { console.error("Error generating PDF:", err); alert("Could not generate PDF. Please try again."); } finally { contentToPrint.style.display = 'none'; } } // --- EVENT LISTENERS --- checkBtn.addEventListener('click', handleCheckText); downloadPdfBtn.addEventListener('click', handlePdfDownload); // --- INITIALIZATION --- lucide.createIcons(); });
Scroll to Top