This project provides a minimal REST API for printing PDF files and listing printers using CUPS.
To run with Docker:
docker build -t cups-rest-api .
docker run -it --rm -p 4567:4567 -p 631:631 -v ./config:/etc/cups cups-rest-api:latestFor other configuration options, see https://github.com/anujdatar/cups-docker/, which this Dockerfile is mostly copied from.
- Endpoint:
GET /printers - Description: Returns a list of available printers with their names and descriptions.
- Example:
curl http://localhost:4567/printers
- Endpoint:
POST /printers/your_printer_name/jobs - Description: Print a PDF by sending the PDF data in the request body.
- Parameters:
printer_name(path parameter): Name of the printer to use.- Optional: Print options as query parameters.
- Example:
curl -X POST \ -H "Content-Type: application/pdf" \ --data-binary @file.pdf \ "http://localhost:4567/printers/PRINTER_NAME/jobs"
You can manage CUPS settings and printers via the CUPS web interface at http://localhost:631, if exposed.
The Dockerfile is mostly copied from https://github.com/anujdatar/cups-docker/.