A PDF generation service for Cloudflare Workers deployment.
🚀 Live Demo: https://x2pdf.1funlab.com/api/pdf
- Generate PDF resumes from JSON data
- Serverless deployment on Cloudflare Workers
- Complete PDF generation API with CORS support
- High performance and global edge distribution
- TypeScript implementation with full type safety
npm install
npm run devThis starts a local development server using Wrangler.
npm run deployDeploy to Cloudflare Workers in production.
npm run deploy:devDeploy to Cloudflare Workers development environment.
GET /- Service informationGET /health- Health checkPOST /api/pdf- Generate PDF (binary response)POST /api/pdf/json- Generate PDF (JSON response with base64)
The service is deployed and available at: https://x2pdf.1funlab.com
curl -X POST https://x2pdf.1funlab.com/api/pdf \
-H "Content-Type: application/json" \
-d '{"name": "John Doe", "contact": {"email": "john@example.com", "phone": "123-456-7890"}}' \
--output resume.pdfcurl -X POST https://x2pdf.1funlab.com/api/pdf/json \
-H "Content-Type: application/json" \
-d '{"name": "John Doe", "contact": {"email": "john@example.com", "phone": "123-456-7890"}}'You can test the API using Postman as shown in the screenshot below:
The screenshot shows how to:
- Set the request method to POST
- Use the endpoint
/api/pdfor/api/pdf/json - Set Content-Type header to
application/json - Include resume data in the request body
The service is deployed on Cloudflare Workers with custom domain routing:
This screenshot shows the production deployment status in the Cloudflare Workers dashboard, including:
- Deployment history and status
- Custom domain configuration (x2pdf.1funlab.com)
- Performance metrics and analytics
- Worker version management
/src/worker.ts- Main Cloudflare Workers implementation (TypeScript)/src/test-pdf-generation.ts- PDF generation test script/src/test-api.ts- API testing script/dist/- Compiled JavaScript files/wrangler.jsonc- Workers deployment configuration/sample.json- Example JSON data for testing/tsconfig.json- TypeScript configuration/images/1.png- Postman usage example screenshot/images/2.png- Cloudflare Workers deployment dashboard screenshot
npm run dev- Local development with Wrangler (TypeScript hot reload)npm run dev:local- Local development with local runtimenpm run build- Compile TypeScript to JavaScriptnpm run build:worker- Build optimized worker bundle with esbuildnpm run test- Run PDF generation testnpm run test:api- Run API endpoint testsnpm run test:validate- Validate sample.json structurenpm run test:all- Run all testsnpm run deploy- Deploy to productionnpm run deploy:dev- Deploy to development environmentnpm run clean- Clean build artifacts
- Runtime: Cloudflare Workers
- Language: TypeScript
- PDF Generation: pdf-lib
- Build Tool: esbuild + TypeScript compiler
- Development: Wrangler CLI
- Deployment: Cloudflare Workers Platform
Configuration is managed through Cloudflare Workers dashboard or wrangler.toml. See wrangler.jsonc for deployment settings.

