A Microsoft Word Add-in that integrates with Nutrient.io's Document Engine (Processor API) and Viewer API to provide PDF conversion, import, and redaction capabilities.
- Export to PDF: Convert Word documents to PDF (PDF/A, PDF/UA) with live preview
- Import from PDF: Convert PDFs to Word documents using OCR
- Redaction & Metadata Stripping: Remove sensitive information and metadata
- Secure Backend: Vercel serverless functions for CORS and API key protection
- Viewer Integration: Embed processed PDFs in iframe for preview
[Word Add-in (OfficeJS + React)]
↕ retrieves document via Office.context
↓ POST file + instructions
[Vercel Serverless Functions]
├─ /api/build ↔ Nutrient `/build`
└─ /api/viewer-upload ↔ Nutrient `/viewer/documents`
↓ responses (PDF or JSON)
[Word Add-in UI]
↕ embeds PDF in iframe (Viewer)
↕ triggers Save
- Node.js 18+
- Vercel CLI (
npm install -g vercel) - Nutrient.io API keys (Processor + Viewer)
- Microsoft Word (desktop or online)
-
Clone and install dependencies:
git clone <repository-url> cd nutrient-dws-azure-word npm install --legacy-peer-deps
-
Configure environment variables:
# Create .env.local file echo "NUTRIENT_API_KEY=your-processor-api-key" > .env.local echo "NUTRIENT_VIEWER_API_KEY=your-viewer-api-key" >> .env.local
-
Start development servers:
# Terminal 1: Start Vercel dev server (includes API routes) npm run vercel:dev # Terminal 2: Start frontend dev server npm run dev
-
Sideload the add-in:
npm run sideload
-
Deploy to Vercel:
# First time setup vercel login vercel # For production deployment npm run vercel:deploy
-
Configure environment variables in Vercel:
- Go to your Vercel dashboard
- Navigate to Settings → Environment Variables
- Add:
NUTRIENT_API_KEY= your processor API keyNUTRIENT_VIEWER_API_KEY= your viewer API key
-
Update manifest.xml:
- Replace
https://localhost:3000with your Vercel deployment URL - Update
AppDomainsto include your Vercel domain
- Replace
nutrient-dws-azure-word/
├── src/ # Frontend React app
│ ├── components/ # React components
│ ├── services/ # API services
│ ├── types/ # TypeScript definitions
│ └── utils/ # Utility functions
├── api/ # Vercel serverless functions
│ ├── build.ts # PDF conversion endpoint
│ └── viewer-upload.ts # Viewer upload endpoint
├── manifest.xml # Office Add-in manifest
├── package.json # Dependencies and scripts
├── vercel.json # Vercel configuration
└── .env # Environment variables
POST /api/build- Proxy to Nutrient.io build APIPOST /api/viewer-upload- Proxy to Nutrient.io viewer API
// Build API
{
file: File,
instructions: {
format: 'pdf' | 'pdf-a' | 'pdf-ua',
ocr: boolean,
redact: boolean,
stripMetadata: boolean
}
}
// Viewer API
{
file: File
}NUTRIENT_API_KEY- Processor API key for PDF conversionNUTRIENT_VIEWER_API_KEY- Viewer API key for PDF embedding
Vercel automatically handles CORS for serverless functions. The configuration is in vercel.json.
# Frontend
npm run dev # Start development server
npm run build # Build for production
npm run test # Run tests
npm run lint # Lint code
# Vercel
npm run vercel:dev # Start Vercel dev server
npm run vercel:deploy # Deploy to production
# Office Add-in
npm run sideload # Sideload add-in to Word
npm run validate # Validate manifest- CORS Errors: Vercel handles CORS automatically
- API Key Errors: Verify environment variables are set in Vercel dashboard
- Office.js Loading: Check manifest.xml source location
- Build Failures: Ensure all dependencies are installed with
--legacy-peer-deps
Enable debug logging in Vercel functions by adding console.log statements.
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
MIT License - see LICENSE file for details
For issues and questions:
- Check the developer handover document
- Review Nutrient.io API documentation
- Contact the development team