This set of scripts explore how to make a CUPS printer which actually sends the print job as a bitmap (jpeg) files.
The CUPS backend is written in bash and uses:
- GhostScript to render the PostScript print job to jpeg
- cURL to send the jpeg files to server
- notify-send to interact with the user (but I haven’t been able to get this work)
The server software is written in PHP and:
- needs a httpd-writeable path for resulting files (e.g. ./files/)
Install
The zip file contains all necessary scripts.
CUPS backend
cp meb /usr/lib/cups/backend
chown root.root /usr/lib/cups/backend/meb
chmod 744 /usr/lib/cups/backend/meb
Receiving Server
- Place the server file (index.php) to whatever location to your PHP-enabled web server
- Create a directory for job files and make this writeable to your web server
- Edit the $FILES_PATH to point to this directory (relative paths are ok)
Create the CUPS printer
Create the CUPS printer with following command:
lpadmin -p [PRINTER_NAME] -m postscript -v "[SERVER_URI]" -D "[DESCRIPTION]" -L "[DESCRIPTION]" -E -P ./Generic-PostScript_Printer-Postscript.ppd -o PageSize=A4
- [PRINTER_NAME] is the name of your printer (e.g. “demoprn”)
- [SERVER_URI] points to the index.php (e.g. “meb://yourhost/path/to/index.php”). Note that the backend contacts the server with http (not https).
- [DESCRIPTION] is the printer description (-D) and location (-L) shown to the user (e.g. “Bitmap Test Printer”)
- You’ll get the ppd file from openprinting.org:
- Select “Generic PostScript Printer”
- Select “download”
- Click “Generate PPD file”
Testing
Now your should see the newly created printer. You may debug the printing process from /tmp/meblog.txt.
Discussion
Technically speaking the approach works. The client sends the bitmap files to server which stores them.
The script is able to send the progress notifications to the user using notify-send (Debian package libnotify-bin). For this the backend searches the user’s DBUS_SESSION_BUS_ADDRESS environment variable from the user’s process information.
For some reason my installation produced hanging /tmp/foomatic-XXXXXX files. No idea who does not take care of its cleanup.
The http upload fails if the number of pages is high and therefore the size of the resulting files exceed the maximum settings in your php.ini (upload_max_filesize and post_max_size).