We will walk through the steps to build a document analysis web application using Nuxt 3 and Azure Document Intelligence. This application allows users to -
upload PDF or images
specify fields (if needed)
extract specific fields of information
Features will include -
🔍 Extract custom fields from identification documents
🔄 Real-time document analysis status
💾 Download extracted data as JSON
🎨 UI with Shadcn-vue /Tailwind CSS
Here’s a quick demo.
While the demo covers only identification documents, the same program can be extended to any document type - application forms, invoices, etc.
Prerequisites
Before we start, make sure you have the following:
Node.js 18.x or later
An Azure account with a Document Intelligence resource
Azure Document Intelligence API key and endpoint
Step 1: Setting Up the Project
Create a blank Nuxt app..
1
pnpx nuxi@latest init docformist
Get your API key and environment details from Azure site. You can sign up for free and use a Free plan to test out the service.
Create a .env file in the root directory with your Azure credentials:
// filepath: /c:/dev/1p/nuxt/docformist/pages/index.vue
<template><!--...existingcode...--></template><scriptsetuplang="ts">constselectedFile=ref<File|null>(null);constextractedData=ref<Record<string,any>|null>(null);constloading=ref(false);constselectedFields=ref<string[]>([]);consthandleFileSelect=(file:File)=>{selectedFile.value=file;extractedData.value=null;};consthandleExtract=async()=>{if(!selectedFields.value.length){console.error("No fields selected");return;}loading.value=true;try{constformData=newFormData();formData.append("file",selectedFile.value!);formData.append("fields",JSON.stringify(selectedFields.value));constresponse=awaitfetch("/api/analyze",{method:"POST",body:formData,});if(!response.ok){thrownewError("Failed to analyze document");}extractedData.value=awaitresponse.json();}catch(error){console.error("Error analyzing document:",error);// TODO: Show error toast
}finally{loading.value=false;}};</script>
Step 7: Run the Application
Start the development server:
1
pnpm dev
Visit http://localhost:3000 to upload a document and see the results.
Conclusion
That was a quick demo of how we build a document analysis / identification app using Azure Document Intelligence. Customize the application further to meet your needs.