You are not logged in.
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:
[c]/var/spool/PDFPrinter IN_CLOSE_WRITE /usr/bin/PDFPrint.sh $# $%[/c]
- 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...)
Offline
Good idea! Can you test this 4k solution with your printer ?
http://tank.slitaz.org/~bellard/printpdf.tgz
Thanks.
Offline
Hi Bellard,
thanks for the interest and sorry for the delay, I was on holiday WITHOUT any computer (my wife was grateful...!)
As for your 4k solution: the printing dialog opens, all parameters can be selected, "some" data is sent to the printer (it wakes up), but nothing is printed.
I had this phenomenon when I worked on my scripts, too; I think some of the PJL overhead may be buggy...
I will try to investigate and be back!
Cheers!
Filou
Offline
Hi again,
after a deeper analysis of what you did (as far as I understand) I really like your generic way of querying the printer and offering all available options to the user.
I was able to print a couple of pdfs using your tazbox script but some also failed (I could not identify the exact problem, I think I have to analyse the resulting PJL-file by saving it instead of sending it to the printer).
I created a PS-file using a print from a PDF out of evince. I saw that the header contains a "%!PS-Adobe" instead of "%PS-ADOBE" since it was created by cairo; maybe the script should be altered/augmented here?
The PS produced an error: the printout said:
ERROR: ioerror
OFFENDING COMMAND: filter
STACK: cairo_paint_form-0, --filestream--, --dict--, SubFileDecode,
All in all for the moment: I like the university, but am not a big fan of the "manuality".
By leaving out the aspect of incron, you have a very universal and tiny tool to send a PS/PDF file to a supporting printer, but have to send the file manually.
What you lose is the "driver-like-feeling" while sending the file directly from another Application like LibreOffice for example.
Nonetheless, one could combine your tazbox-solution with the incrond variant anyway...
I will try to check out, what files fail and why in the coming days...
Cheers,
Filou
Offline
Hi Filou,
Thanks for the report. The tazbox script will be in the next rolling with your fix:
http://hg.slitaz.org/slitaz-tools/rev/09a408773b37
Maybe we can use busybox lpd http://cook.slitaz.org/index.cgi?stuff=../wok/busybox/source/busybox-1.31.1/printutils/lpd.c and create the HELPER-PROG wrapper instead of incron ?
Regards,
Pascal
Offline
Hi Pascal,
although I would be fond of the idea to use busybox lpd, we then would have to create some script that converts the print content to PDF or Postscript.
The incrond solution depends on the PDF being created by your Application (Browser, Office or Whatever) and simply saved to the used directory. If LibreOffice pushes any document content to lpd, i doubt that the format will be pdf or PS ?!?
The problem arising with lpd would be to identify the content type and converting it to PDF/PS.
I just wanted to use the (anyway) builtin feature of Applications being able to save as PDF...
Best Regards,
Nils
Offline
[ Generated in 0.021 seconds, 7 queries executed - Memory usage: 1.55 MiB (Peak: 1.77 MiB) ]