A high-performance REST API service built with Deno that converts PDF documents to WebP images. The service processes PDFs, optimizes the images with Sharp, and returns a ZIP archive containing WebP images for each page.
- 🚀 Fast PDF to WebP conversion
- 📦 Returns all pages as a ZIP archive
- 🛡️ Built with Deno for enhanced security
- Deno 2.x or higher
- Clone the repository
- Install Deno if you haven't already: https://deno.land/manual/getting_started/installation
deno install --allow-scripts
deno task start
The server will start on port 8787 by default. You can customize the port by setting the PORT
environment variable.
- GET /
- Returns "ok" if the server is running
- POST /pdf-to-images
- Content-Type: multipart/form-data
- Request body:
pdf
: PDF file to convert
Response:
- 200: ZIP archive containing WebP images for each page
- 400: Error if no PDF file is uploaded
- 500: Server error with error message
Using cURL:
curl -X POST -F "pdf=@/path/to/your/document.pdf" http://localhost:8787/pdf-to-images -o pages.zip
The project includes K6 load testing configuration. To run the load tests:
- Set the PDF_PATH environment variable to your test PDF file
- Run the test:
k6 run --env PDF_PATH=/path/to/your/test.pdf ./k6.js
Build
docker build . -t pdf2images:latest
Run
docker run -p 8787:8787 --rm pdf2images:latest
You should have az cli installed with a resource group and container registry initialized
- Login to your ACR registry
az acr login --name <your-registry-name>
- Build and push the Docker image to ACR:
docker build --platform linux/amd64 -t <your-registry-name>.azurecr.io/pdf2images:latest .
docker push <your-registry-name>.azurecr.io/pdf2images:latest
- Deploy the container app using the UI
Your API will now be accessible at the URL shown in the deployment output.
This project is licensed under the GNU General Public License v3.0 - see the LICENSE file for details.