Here is a basic HTML and JavaScript code for the Document Scanner application:
HTML:
“`
Document Scanner
“`
JavaScript:
“`
const uploadForm = document.getElementById(‘upload-form’);
const uploadButton = document.getElementById(‘upload-button’);
const documentInput = document.getElementById(‘document’);
const resultDiv = document.getElementById(‘result’);
uploadButton.addEventListener(‘click’, (e) => {
e.preventDefault();
const file = documentInput.files[0];
if (!file) {
alert(‘Please select a file’);
return;
}
const formData = new FormData();
formData.append(‘document’, file);
fetch(‘/upload’, {
method: ‘POST’,
body: formData
})
.then((response) => response.json())
.then((data) => {
resultDiv.innerHTML = `
Document Scanner Result
Document Name: ${data.documentName}
Document Type: ${data.documentType}
Extracted Text: ${data.extractedText}
`;
})
.catch((error) => console.error(‘Error:’, error));
});
“`
CSS (in style.css file):
“`
body {
font-family: Arial, sans-serif;
}
.container {
width: 80%;
margin: 40px auto;
padding: 20px;
background-color: #f9f9f9;
border: 1px solid #ddd;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
#upload-form {
margin-bottom: 20px;
}
#result {
margin-top: 20px;
}
“`