WebPrint Service

Service for making connection between remote WebPrint Server and local printers.

GitHub RepositoryDownload webprint-service.phar

Setup

You can install webprint-service tool in four ways:

  • As a Docker image - see Docker Setup
  • Global composer installation - tool will be available globally as webprint-service command
  • You can download phar executable file from GitHub Releases page
  • Download source code form GitHub to run
Docker
docker pull ghcr.io/kduma-oss/webprint-service:latest
Composer Global
composer global require kduma/webprint-service-cli
phar executable
wget https://github.com/kduma-OSS/WebPrint-Service/releases/latest/download/webprint-service.pharchmod +x webprint-service.pharmv webprint-service.phar /usr/local/bin/webprint-service
Sources
git clone https://github.com/kduma-OSS/WebPrint-Service.git webprint-servicecd webprint-servicecomposer install

Environmental Variables

Environmental Variable NameDescription
WEBPRINT_SERVER_ENDPOINTAn url pointing to the WebPrint Server, ending with /api/print-service endpoint
WEBPRINT_SERVICE_KEYAPI Key generated for your WebPrint Service instance
DEBUG_OUTPUT_DIRECTORYOutput directory for print jobs sent to debug://debug protocol
POLL_TIME_CALCULATOR_CONFIGKey to configure how often to check for new jobs - defaults to constant.

Available Poll Time Configurations

Constant Poll Time with long polling enabled:

constant?delay=1000&poll=true

When you can't use long polling, disable it and increase delay - for example, every 10 seconds:

constant?delay=10000&poll=false

Dynamic Poll Time - when no new jobs are present, the time between checks will be increasing:

dynamic?initial_delay=1000&max_delay=60000&multiplier=1.02&backoff=0&warmup=0

Docker Setup

This tool has been packaged as Docker image. For deployment, you can create your own docker-compose.yml file based on docker-compose.yml from source repository.

Alternatively you can deploy images directly, using docker run commands. You can use following example command:

docker run --detach --restart always \  --volume $(pwd):/tmp/webprint-service-debug-output \  --env WEBPRINT_SERVER_ENDPOINT="http://webprint-server/api/print-service" \  --env WEBPRINT_SERVICE_KEY="1|DEBUG_WEBPRINT_SERVICE_KEY" \  --env CUPS_SERVER=cups:631 \  --hostname webprint-service \  --name webprint-service \  ghcr.io/kduma-oss/webprint-service:latest

Publishing /tmp/webprint-service-debug-output volume is optional, as it is only used when print jobs are sent to printer configured with debug:// protocol. Environmental values WEBPRINT_SERVER_ENDPOINT and WEBPRINT_SERVICE_KEY, set accordingly to Environmental Variables section above. If you want to use CUPS print server with WebPrint Service, you need to also set CUPS_SERVER environmental variable to point to your CUPS server instance.

If you don't have CUPS server already installed, you can use following docker image:

docker run --detach --restart always \  --volume $(pwd):/etc/cups \  --env ADMIN_PASSWORD=mySecretPassword \  --hostname cups \  --name cups \  --expose 631 \  --publish 631:631 \  ydkn/cups:latest

For more information about this CUPS Docker Image, check ydkn/cups page on Docker Hub.

Raspberry Pi Setup

This section will be coming soon.

QNAP Container Station Setup

This section will be coming soon.

Usage

This executable provides two tools, for using with WebPrint Server.

Watching for incoming jobs

Main deamon-mode command for pooling new print jobs. This command should be automatically restarted using something like Supervisord.

./webprint-service watch

Parsing PPD definition files

A tool for parsing PPD file to format acceptable in Printer configuration on WebPrint Server. Provide path to .ppd file in <file> argument, and as an STDOUT output you will get PPD Options in JSON format. If you want to export in PHP Array format, set the --array flag.

./webprint-service ppd:parse <file> {--array}

Supported Print Protocols

This section will be coming soon.

lpd:// - LPD Protocol

Available configuration options:

  • host is required
  • port is optional (defaults to 515)
  • queue/path is optional
  • timeout is optional (defaults to 60)
  • tries is optional (defaults to 1)

Example Configuration URI:

lpd://192.168.1.5:515/ldp1?timeout=60&tries=1

socket:// - RAW Socket Protocol

Available configuration options:

  • host is required
  • port is optional (defaults to 9100)
  • timeout is optional (defaults to null)

Example Configuration URI:

socket://192.168.1.5:9100/?timeout=60

cups:// - CUPS Client

Available configuration options:

  • Only printer name is required - needs to be exactly as configured in CUPS server

Example Configuration URI:

cups://PRINTER_NAME

debug:// - Debug Dumper

Available configuration options:

  • no configurable options available

Example Configuration URI:

debug://debug