BentoPDF Deployment and Usage Guide
1. Prerequisites
Runtime & Tools:
- Node.js (v18 or later) - Required for building and running the development server
- npm or yarn - Package manager for JavaScript dependencies
- Git - For cloning the repository
- Docker (optional) - For containerized deployment
- Podman (optional) - Alternative to Docker, especially for Podman Compose/Quadlet deployments
For Self-Hosting WASM Modules (Optional):
- Web server (Nginx, Apache, or similar) for serving WASM files
- Cloudflare account (optional) for deploying proxy workers
Accounts (Optional):
- Cloudflare account for deploying CORS proxy workers
- DigitalOcean, Vercel, Netlify, or similar for static hosting
- Docker Hub or GitHub Container Registry for container images
2. Installation
Clone the Repository
git clone https://github.com/alam00000/bentopdf.git
cd bentopdf
Install Dependencies
npm install
# or
yarn install
Verify Installation
npm run build
# Should complete without errors
3. Configuration
Environment Variables
Create a .env file in the project root for local development:
# Development server port (optional)
PORT=3000
# WASM configuration (optional - uses CDN by default)
# VITE_PYMUPDF_WASM_URL=https://cdn.jsdelivr.net/npm/@bentopdf/pymupdf-wasm/dist/
# VITE_GS_WASM_URL=https://cdn.jsdelivr.net/npm/@bentopdf/ghostscript-wasm/dist/
# VITE_CPDF_WASM_URL=https://cdn.jsdelivr.net/npm/@bentopdf/cpdf-wasm/dist/
WASM Configuration
By default, BentoPDF uses CDN-hosted WASM modules. For custom deployments:
- Self-hosted WASM: Set the environment variables above to point to your own servers
- Air-gapped/Offline: Pre-download WASM files and serve them locally
- Cloudflare Proxy: Deploy the included WASM proxy worker for CORS support
Digital Signature CORS Proxy
For digital signature functionality, deploy the CORS proxy worker:
- Navigate to the
cloudflare/directory - Set up
wrangler.tomlwith your Cloudflare account ID - Configure environment variables:
[vars] PROXY_SECRET = "your-shared-secret-here" - Deploy:
npx wrangler deploy
Custom Branding
To customize the application appearance, modify:
public/images/- Logo and favicon filessrc/directory - UI components and styles- Environment variables for custom theming
4. Build & Run
Development Mode
npm run dev
# or
yarn dev
Access the application at http://localhost:3000
Production Build
npm run build
# or
yarn build
The built files will be in the dist/ directory.
Preview Production Build
npm run preview
# or
yarn preview
Docker/Podman (Single Container)
# Build the image
docker build -t bentopdf .
# Run the container
docker run -p 3000:3000 bentopdf
# With Podman
podman run -p 3000:3000 bentopdf
Docker Compose / Podman Compose (Recommended)
# Using Docker Compose
docker-compose up -d
# Using Podman Compose
podman-compose up -d
Podman Quadlet (Systemd Integration)
- Copy the provided Quadlet configuration to
~/.config/containers/systemd/ - Enable and start the service:
systemctl --user enable --now bentopdf.container
5. Deployment
Static Hosting Platforms
BentoPDF is a static web application and can be deployed to:
Netlify:
npm run build
# Deploy the dist/ folder via Netlify CLI or drag-and-drop
Vercel:
vercel
GitHub Pages:
- Update
vite.config.tswith your base path - Build and deploy:
npm run build # Deploy dist/ folder to gh-pages branch
Cloudflare Pages:
# Connect your repository and set build command:
npm run build
# Output directory: dist
Traditional Web Servers
Nginx Configuration:
server {
listen 80;
server_name your-domain.com;
root /path/to/bentopdf/dist;
location / {
try_files $uri $uri/ /index.html;
}
# WASM files
location ~ \.(wasm|js|mjs)$ {
add_header Content-Type application/wasm;
expires 1y;
add_header Cache-Control "public, immutable";
}
}
Apache Configuration:
<VirtualHost *:80>
ServerName your-domain.com
DocumentRoot /path/to/bentopdf/dist
<Directory /path/to/bentopdf/dist>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
FallbackResource /index.html
</Directory>
# WASM MIME types
AddType application/wasm .wasm
AddType application/javascript .mjs
</VirtualHost>
Docker Registry Deployment
- Build and tag your image:
docker build -t yourusername/bentopdf:latest . - Push to registry:
docker push yourusername/bentopdf:latest - Pull and run on your server:
docker run -d -p 3000:3000 --name bentopdf yourusername/bentopdf:latest
6. Troubleshooting
Common Issues
WASM Modules Not Loading:
Error: Failed to fetch WASM module
Solution:
- Check network connectivity
- Verify CDN URLs in configuration
- For local deployments, ensure WASM files are properly served with correct MIME types
- Deploy the WASM proxy worker for CORS support
Digital Signature Errors:
CORS error when fetching certificates
Solution:
- Deploy the CORS proxy worker from
cloudflare/cors-proxy-worker.js - Verify
PROXY_SECRETenvironment variable matches between worker and client - Check that the proxy URL is correctly configured in the application
Service Worker Cache Issues:
Old version persists after update
Solution:
- Clear browser cache and service worker
- Increment
CACHE_VERSIONinpublic/sw.js - Unregister old service workers in browser developer tools
Build Failures:
npm run build fails
Solution:
- Ensure Node.js version is 18+
- Clear node_modules and reinstall:
rm -rf node_modules package-lock.json npm install - Check for TypeScript errors:
npx tsc --noEmit
Docker/Podman Container Won't Start:
Container exits immediately
Solution:
- Check logs:
docker logs bentopdf # or podman logs bentopdf - Verify port mapping:
docker run -p 3000:3000 bentopdf - Check resource limits (WASM modules require memory)
Performance Issues with Large PDFs:
Browser becomes unresponsive
Solution:
- Use smaller PDF files (<100MB recommended)
- Close other tabs to free memory
- Consider using "Simple Mode" for internal use with smaller files
- Ensure sufficient system RAM (4GB minimum, 8GB recommended)
Offline/Air-Gapped Deployment Issues:
Features don't work without internet
Solution:
- Pre-download all WASM modules
- Configure local URLs in environment variables
- Ensure service worker is properly caching assets
- Test all functionality while disconnected from network
For additional help, join the BentoPDF Discord community or consult the official documentation.