Legal Document Summarizer

Legal Document Summarizer

Paste your legal text below to generate a clear and concise summary.

Data Configuration

Generated Summary

Your summary will appear here after you input your document and click 'Next'.

Disclaimer: This AI-powered tool provides summaries for informational purposes only and does not constitute legal advice. Always consult with a qualified legal professional for critical matters.

${originalText.replace(/\n/g, '
')}

`; } /** * Downloads the generated summary and original text as a PDF file. */ async function downloadPDF() { const { jsPDF } = window.jspdf; const pdfContent = document.getElementById('pdf-render-area'); if (!pdfContent) { console.error('PDF content area not found.'); return; } downloadPdfBtn.textContent = 'Generating...'; downloadPdfBtn.disabled = true; pdfContent.classList.remove('hidden'); try { const canvas = await html2canvas(pdfContent, { scale: 2, windowWidth: pdfContent.scrollWidth, windowHeight: pdfContent.scrollHeight }); const imgData = canvas.toDataURL('image/png'); const pdf = new jsPDF({ orientation: 'portrait', unit: 'in', format: 'letter' }); const pdfWidth = pdf.internal.pageSize.getWidth(); const pdfHeight = pdf.internal.pageSize.getHeight(); const imgProps = pdf.getImageProperties(imgData); const ratio = imgProps.height / imgProps.width; let imgHeight = pdfWidth * ratio; let heightLeft = imgHeight; let position = 0; pdf.addImage(imgData, 'PNG', 0, position, pdfWidth, imgHeight); heightLeft -= pdfHeight; while (heightLeft >= 0) { position = heightLeft - imgHeight; pdf.addPage(); pdf.addImage(imgData, 'PNG', 0, position, pdfWidth, imgHeight); heightLeft -= pdfHeight; } pdf.save('Legal_Document_Summary.pdf'); } catch (error) { console.error('Error generating PDF:', error); } finally { pdfContent.classList.add('hidden'); downloadPdfBtn.textContent = 'Download Summary as PDF'; // Re-enable based on whether content exists if (summaryOutput.textContent.trim() !== '') { downloadPdfBtn.disabled = false; } } } // --- EVENT LISTENERS --- downloadPdfBtn.addEventListener('click', downloadPDF); // --- INITIALIZATION --- showTab(currentTab); });
Scroll to Top