An AI-powered web application for applying company seals to PDF documents with intelligent placement suggestions.
- 🤖 AI-Powered Placement: Uses Azure OpenAI GPT-4.1 vision to analyze documents and suggest optimal seal positions
- 📄 Universal Document Support: Works with any document type (contracts, invoices, letters, certificates, forms)
- ✨ Live Preview: Real-time PDF preview with seal overlay
- 🎯 Manual Controls: Fine-tune seal position, size, and page placement
- 🔒 Secure Access: Password-protected with JWT authentication
- 📥 Easy Download: Apply seal and download modified PDF instantly
- Node.js 20+
- npm or yarn
- Azure OpenAI account with GPT-4.1 deployment
- Clone the repository:
git clone <repository-url>
cd pdf-seal-app- Install dependencies:
npm install- Create
.env.localfile with required variables:
AZURE_OPENAI_ENDPOINT=https://your-resource.openai.azure.com
AZURE_OPENAI_API_KEY=your-api-key
AZURE_OPENAI_DEPLOYMENT=gpt-4.1
MASTER_PASSWORD=your-password
JWT_SECRET=your-jwt-secret- Run the development server:
npm run dev- Open http://localhost:3000 in your browser
npm run build
npm start- Upload PDF: Drag and drop or select a PDF document
- AI Analysis: Click "AI Suggest Position" to get intelligent placement recommendations
- Manual Adjustment: Fine-tune position, size, and page using controls
- Preview: See real-time preview of seal placement
- Apply & Download: Generate and download the sealed PDF
- Framework: Next.js 15 with Turbopack
- UI: React 19, Tailwind CSS 4, Radix UI
- PDF Processing: pdf-lib, Puppeteer, react-pdf
- AI: Azure OpenAI GPT-4.1 Vision
- Authentication: JWT with jose library
- Image Processing: Sharp, Canvas
- Converts PDF pages to high-resolution images using Puppeteer (headless Chrome)
- Sends images to GPT-4.1 vision API for intelligent analysis
- Generalized prompts work with any document type without hardcoded assumptions
- Returns coordinates, reasoning, and confidence score
- No system-level dependencies required
- Puppeteer bundles Chromium browser
- All processing done with npm packages
- 8x resolution seal rendering for print quality (300 DPI)
- SVG to PNG conversion with sharp
- Preserves PDF quality and structure
npm run dev # Start development server with Turbopack
npm run build # Build for production
npm start # Start production server
npm run lint # Run ESLint├── app/
│ ├── api/
│ │ ├── analyze-pdf/ # AI vision analysis endpoint
│ │ ├── apply-seal/ # Seal application endpoint
│ │ └── auth/ # Authentication endpoints
│ ├── login/ # Login page
│ └── page.tsx # Main application
├── components/
│ ├── Header.tsx # Top navigation
│ ├── PdfUploader.tsx # File upload component
│ ├── PdfPreview.tsx # PDF viewer with seal overlay
│ └── SealEditor.tsx # Control panel
├── lib/
│ ├── azure-openai.ts # AI vision integration
│ ├── pdf-to-image.ts # PDF rendering with Puppeteer
│ ├── pdf-processor.ts # PDF manipulation
│ └── auth.ts # JWT authentication
└── types/
└── index.ts # TypeScript definitions
| Variable | Description | Required |
|---|---|---|
AZURE_OPENAI_ENDPOINT |
Azure OpenAI resource endpoint | Yes |
AZURE_OPENAI_API_KEY |
Azure OpenAI API key | Yes |
AZURE_OPENAI_DEPLOYMENT |
Deployment name (use gpt-4.1) | Yes |
MASTER_PASSWORD |
Application access password | Yes |
JWT_SECRET |
Secret for JWT token signing | Yes |
- Password-protected access with JWT sessions
- 24-hour session expiration
- HTTP-only cookies
- Secure flag enabled in production
- Middleware-based route protection
Contributions are welcome! Please ensure all changes:
- Follow existing code style
- Include appropriate error handling
- Work with the generalized AI prompt system
- Maintain PDF coordinate system conventions (origin at bottom-left)
This project is private and proprietary.
For issues or questions, please contact the development team.