Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Docker PDF Printer

A lightweight Docker-based PDF printing utility designed to print PDF documents from Linux systems without installing CUPS or printer drivers on the host.

The current implementation targets the Samsung Xpress M2026 / M2020 Series, but the long-term goal is to support multiple printer models through interchangeable drivers and configuration profiles.

Roadmap

Planned improvements include:

  • Support for additional printer models.
  • Configurable printer profiles.
  • Automatic driver selection.
  • Network (IPP/JetDirect) printers.
  • Multiple paper sizes and media types.
  • Support for printing non-PDF file formats (e.g., images, text, and office documents).
  • Simple command-line interface.

Features

  • No CUPS installation required on the host.
  • No printer drivers installed on the host.
  • USB printer support.
  • Automatic printer detection.
  • Automatic printer configuration.
  • PDF printing from any mounted directory.
  • Configurable paper size (currently A4 and A5).

Requirements

Host requirements:

  • Docker
  • Linux
  • A supported USB printer

Verify that the printer is visible:

lsusb

Example:

Bus 001 Device 010: ID 04e8:3321 Samsung Electronics Co., Ltd M2020 Series

Project structure

.
├── Dockerfile
├── print.sh
└── README.md

Building

docker build -t samsung-m2026-print .

Printing

The basic syntax is:

docker run --rm \
    --privileged \
    -v "$PWD:/work" \
    samsung-m2026-print \
    /work/file.pdf [PAGE_SIZE]

The second argument is optional.

If omitted, A4 is used.

Examples:

Print on A4:

docker run --rm \
    --privileged \
    -v "$PWD:/work" \
    samsung-m2026-print \
    /work/document.pdf

or explicitly:

docker run --rm \
    --privileged \
    -v "$PWD:/work" \
    samsung-m2026-print \
    /work/document.pdf A4

Print on A5:

docker run --rm \
    --privileged \
    -v "$PWD:/work" \
    samsung-m2026-print \
    /work/menu.pdf A5

Supported page sizes

Current implementation:

Argument CUPS option
A4 PageSize=A4
A5 PageSize=A5

Additional paper sizes can easily be added by extending print.sh and rebuilding.


Rebuilding

Whenever Dockerfile or print.sh changes:

docker build -t samsung-m2026-print .

Debugging

Open an interactive shell:

docker run --rm -it \
    --privileged \
    --entrypoint bash \
    -v "$PWD:/work" \
    samsung-m2026-print

Start CUPS:

service cups start

Available USB devices:

lsusb

Printer URI:

lpinfo -v

Installed printer drivers:

lpinfo -m | grep splix

Printer capabilities:

lpoptions -p Samsung_M2026 -l

Why does the container wait after printing?

After submitting a print job, CUPS returns immediately, but the printer backend may still be transferring data to the USB device.

If the container exits too quickly, the USB backend may terminate before the printer has completely received the job. On some printers this results in behavior where the printer starts, makes its usual initialization noise, and then stops without feeding paper. Running the same command a second time often succeeds because the printer is already awake.

To avoid this race condition, the script waits for the print queue to finish and then deliberately keeps the container alive for an additional 10 seconds before exiting. This ensures the USB transfer has enough time to complete reliably.

The delay is not strictly required by CUPS itself; it is a practical reliability measure for short-lived containers.


Notes

This project currently uses:

  • Debian Bookworm
  • CUPS
  • Ghostscript
  • SpliX printer drivers

The Samsung M2026 does not understand PDF directly.

The container automatically converts PDF documents into the printer language required by the device before sending them over USB.

No printer software is installed on the host.


Limitations

  • USB printers only.
  • Currently tested with Samsung Xpress M2026 / M2020 Series.
  • Requires Docker --privileged to access USB devices.

License

This project is licensed under the GNU General Public License v3.0 (GPLv3).

About

A lightweight Docker-based printing utility

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages