It somehow felt strange to me to have a lightweight distro of compressed ~50 MB and at the same time having the necessity to install a printer driver of more than 65MB of installation files...
When realizing that my HP Color LaserJet MFP network printer is able to print a PDF directly, without any driver necessities, I did exactly that by sending the file via netcat to the printer.
What was lacking was the possibility to edit the main parameters: Duplex printing (e.g. double sided), Eco-Mode, number of copies...
I had a look in the Printer-Language PJL which gives some straightforward possibilities to edit exactly these parameters by appending some lines of code to the beginning of the PDF.
What I finally did was writing some lines of code calling a small YAD-interface asking the above mentioned three questions, creating the resulting PJL/PDF file and sending it to the printer via netcat.
The script is triggered by incron.d, a daemon that supervises the filesystem and can be configured to start scripts when a file is added to a directory (or edited or removed or ....).
So what do you need?
- install incron via tazpkg -gi incron
- edit /etc/incron.allow and add all users who should use the "driver"
- add a directory /var/spool/incron/
- create a file named as the user in /var/spool/incron (ex.: /var/spool/incron/tux) containing this code:
/var/spool/PDFPrinter IN_CLOSE_WRITE /usr/bin/PDFPrint.sh $# $%
- create a directory /var/spool/PDFPrinter (or as you like, but must match the scripts !)
- chgrp lp /var/spool/PDFPrinter (to have users of group "lp" have access)
- chmod g+w /var/spool/PDFPrinter (to let the users have write access)
- create a file /usr/bin/PDFPrint.sh like as in:
https://gist.github.com/F1lou/bc753e80fc07f5977c71e0f8ab3c4b2f
- open /var/spool/PDFPrinter in pcmanfm and add a favourite
As a result I can print files from every program that exports directly to PDF, eg.:
- LibreOffice
- FreeOffice
- Almost all Browsers
- evince (with the possibility to print only selected pages or resizing)
by simply exporting / "printing" to the folder /var/spool/PDFPrinter. Alternatively, you can simply copy the PDF-file to the /var/spool/PDFPrinter folder.
The resulting "driver" size is about 150kB...
(Yes, I know that there is no real driver functionality, but I don't need any filtering function, only the printout of the content...)