Data Extraction from Documents Tool

Data Extraction from Documents Tool

Paste Document Text Here

Extracted Data

Results will appear here after extraction.

Could not extract structured data. Please check the text format.

'; downloadPdfBtn.classList.add('hidden'); } else { downloadPdfBtn.classList.remove('hidden'); } resultsOutput.innerHTML = html; }; /** * Generates and downloads a PDF of the extracted data. */ const generatePdf = () => { const { jsPDF } = window.jspdf; const doc = new jsPDF(); let yPos = 20; doc.setFontSize(18); doc.text('Extracted Document Data', 14, yPos); yPos += 15; // Key-Value Pairs const kvpSection = resultsOutput.querySelector('h3'); if (kvpSection && kvpSection.textContent === 'Key Information') { doc.setFontSize(14); doc.setFont(undefined, 'bold'); doc.text('Key Information', 14, yPos); yPos += 8; const pairs = Array.from(kvpSection.nextElementSibling.children).map(div => { return [div.querySelector('strong').textContent, div.querySelector('span').textContent]; }); doc.autoTable({ startY: yPos, body: pairs, theme: 'plain', styles: { fontSize: 10, cellPadding: 1.5 }, columnStyles: { 0: { fontStyle: 'bold' } } }); yPos = doc.lastAutoTable.finalY + 10; } // Tables const tableEl = resultsOutput.querySelector('table'); if (tableEl) { const tableTitle = resultsOutput.querySelector('h3:last-of-type').textContent; doc.setFontSize(14); doc.setFont(undefined, 'bold'); doc.text(tableTitle, 14, yPos); yPos += 8; doc.autoTable({ html: tableEl, startY: yPos, theme: 'grid', headStyles: { fillColor: [243, 244, 246], textColor: [55, 65, 81], fontStyle: 'bold' }, styles: { cellPadding: 2.5, fontSize: 9 }, }); } doc.save('Extracted_Data.pdf'); }; // --- Event Listeners --- extractBtn.addEventListener('click', extractData); downloadPdfBtn.addEventListener('click', generatePdf); });
Scroll to Top