Document Metadata Analyzer

Document Metadata Analyzer

Input document details to analyze and summarize key metadata points.

No document data configured. Please go to the 'Data Configuration' tab to add documents.

Add & Edit Document Metadata

No document data configured. Please go to the 'Data Configuration' tab to add documents.

`; return; } let totalFiles = documentItems.length; let totalSizeKB = 0; const fileTypeCounts = {}; const authorCounts = {}; const documentData = []; documentItems.forEach(item => { const inputs = item.querySelectorAll('input, select'); const fileSize = parseFloat(inputs[3].value) || 0; const fileType = inputs[1].value; const author = inputs[2].value.trim(); totalSizeKB += fileSize; fileTypeCounts[fileType] = (fileTypeCounts[fileType] || 0) + 1; if (author) { authorCounts[author] = (authorCounts[author] || 0) + 1; } documentData.push({ name: inputs[0].value || 'N/A', type: fileType, author: author || 'N/A', size: fileSize, created: inputs[4].value || 'N/A', modified: inputs[5].value || 'N/A' }); }); const mostCommonFileType = Object.keys(fileTypeCounts).reduce((a, b) => fileTypeCounts[a] > fileTypeCounts[b] ? a : b, 'N/A'); const totalSizeMB = (totalSizeKB / 1024).toFixed(2); let dashboardHTML = `

Analysis Summary

Total Documents

${totalFiles}

Total Size

${totalSizeMB} MB

Most Common Type

${mostCommonFileType}

Document Details

`; documentData.forEach(doc => { dashboardHTML += ` `; }); dashboardHTML += `
File Name Type Author Size (KB) Last Modified
${doc.name} ${doc.type} ${doc.author} ${doc.size.toLocaleString()} ${doc.modified}
`; dashboardOutput.innerHTML = dashboardHTML; } /** * Handles the PDF download functionality. */ function downloadPDF() { const { jsPDF } = window.jspdf; const documentItems = document.querySelectorAll('.document-item'); if (documentItems.length === 0) { console.warn("No data to export."); return; } const doc = new jsPDF(); const tableData = Array.from(documentItems).map(item => { const inputs = item.querySelectorAll('input, select'); return [ inputs[0].value || '', // File Name inputs[1].value || '', // File Type inputs[2].value || '', // Author parseFloat(inputs[3].value || 0).toLocaleString(), // File Size inputs[4].value || '', // Creation Date inputs[5].value || '' // Last Modified ]; }); doc.setFontSize(18); doc.text('Document Metadata Analysis Report', 14, 22); doc.setFontSize(11); doc.setTextColor(100); doc.text(`Report generated on: ${new Date().toLocaleDateString()}`, 14, 30); doc.autoTable({ head: [['File Name', 'Type', 'Author', 'Size (KB)', 'Created', 'Last Modified']], body: tableData, startY: 35, theme: 'grid', headStyles: { fillColor: [2, 132, 199] }, // Sky-600 }); doc.save('Document-Metadata-Analysis.pdf'); } // --- Event Listeners --- if (addDocumentBtn) { addDocumentBtn.addEventListener('click', addDocumentForm); } if (downloadPdfBtn) { downloadPdfBtn.addEventListener('click', downloadPDF); } // --- Initial Setup --- updateNavButtons(); generateDashboard(); });
Scroll to Top