This repository contains a FastAPI-based application for converting PDF, images, and HTML to ZPL format.
- Convert PDF, PNG, JPG, JPEG, and HTML files to ZPL format.
- Supports ASCII, B64, and Z64 ZPL formats.
- Options to invert colors, use dithering, and set DPI.
- Split PDF pages into separate ZPL files.
- Docker
-
Clone the repository:
git clone <repository-url> cd <repository-directory>
-
Build the Docker image:
docker build -t zpl-converter-api .
-
Run the Docker container:
docker run -p 8000:8000 zpl-converter-api
-
The application will be accessible at
http://localhost:8000.
Swagger UI is available at http://localhost:8000/docs.
-
URL:
/convert/html -
Method:
POST -
Request Body:
{ "html_content": "<html>Your HTML content here</html>", "options": { "format": "ASCII", "width": 4.0, "height": 6.0, "scale": 1.0, "invert": false, "dpi": 203 } } -
Response:
{ "status": "success", "zpl_content": "^XA^FO50,50^ADN,36,20^FDZPL encoded image^FS^XZ", "timestamp": "2023-10-01T12:00:00Z" }
-
URL:
/upload_pdf -
Method:
POST -
Request Body:
{ "file_content": "base64_encoded_pdf_content", "options": { "format": "ASCII", "invert": false, "dither": true, "threshold": 128, "dpi": 203, "split_pages": true } } -
Response:
{ "status": "success", "zpl_content": "^XA^FO50,50^ADN,36,20^FDZPL encoded image^FS^XZ", "timestamp": "2023-10-01T12:00:00Z" }
MAX_UPLOAD_SIZE: Maximum upload size in bytes (default: 10MB).PORT: Port to run the application (default: 8000).
This application can be deployed using Render. The configuration is provided in the render.yaml file.
This project is licensed under the MIT License.