PDF Network Printing Without Drivers

Finally a plug and play local pdf to printer system

I’ve created a small docker container that exposes an API and a web interface to receive pdf files and forward them to an IPP printer on the network.

Dockerhub GitLab Source Code

If you like this project, please star it on GitLab and Dockerhub.

Why build something like this?

I needed an easy way for me as a human to print PDF files from all sorts of devices before I created this I used google CloudPrint which was great but they are shutting down the service. Also, it wasn’t flexible to be used with random scripts without jumping through complicated authentication hoops so I’ve created this simple http app that can run anywhere and point to any ipp printer it can reach. It uses cups to setup the connection to the printer and issue commands over IPP there is a simple check in the python server that verifies that it is a usable PDF and that the size is not too small with PyPDF2.

It is probably as plug and play as it gets, although I’m not entirely sure because I have only 1 network printer that I can test with.

How to use?

Run the container and place your printer’s ip in the env var IPP_IP like in this example docker run command:

docker run -d -p 5000:5000 -e "IPP_IP=192.168.1.66" aapjeisbaas/pdf-to-ipp

Now you can reach the web interface of the service at: http://127.0.0.1:5000/

Automate all the things!

This is pretty useful by itself but if you’re anything like me you want to automate your printing. The application expects A4 pdf files to be uploaded to: http://127.0.0.1:5000/uploader in a python function this will look like the one below.


import requests

def send_to_printer(pdf):
    files = {'file': open(pdf, 'rb')}
    requests.post('http://127.0.0.1:5000/uploader', files=files)

send_to_printer('/home/user/pdf/print-this.pdf')

It is cross-build to support all architectures I could think of and I run it on an ARM64 K3S cluster with raspberry pi’s and the container uses about 50MB of RAM.

This does not do X, Y OR Z

Nope, and probably never will.

This is mostly meant as a jumping-off point to “roll your own” and learn a bit about python/docker/cups/ipp along the way. It is not ultra configurable, nor do I need it to be. This thing just prints packing slips for my wife’s webshop and don’t want to overcomplicate things by adding to much “enterprise” sauce.

Do you have more printing projects?

Well, yes and it is even more niche than this one. This project is based on label-container and it takes in, you’ve probably guessed it already: PDF shipping labels, and it prints them on a Dymo 4XL

Cloud & Open-Source magician 🧙‍♂️

I try to find the KISS in complex systems and share it with the world.

comments powered by Disqus