![]() |
Cups and Samba to print one print job to 2 printers - tutorial added
Hey everyone,
I have a samba/cups server setup (on centos 5.3) on which I have been able to successfully setup and share a virtual PDF printer using cups-pdf. I now need the ability to be able to send a print job to 2 printers at once. For instance - A user prints a document that is sent to a printer that prints it out on paper. At the very same time that that happens that very same print job is also sent to the virtual PDF printer and a PDF is created and dumped into a shared directory. I know how to dump the PDF files in the directory I want however I am totally and completely lost on how to have one print job go to both printers. I have been reading that I can create a simple bash script to do this. However I am not sure I understand exactly how this script works. I assume that I would need to place it under "/usr/lib/cups/backend/" but then I am not sure how to call on it. I was also thinking that if I could capture the PS file that is created when the user sends the job I could us that in a script to then print to PDF or vice-versa. My problem with this is I haven't been able to figure out a way to actually capture the PS file that is created. Assuming I have this right - when a user sends a job to a printer the system uses the printer drivers to create a PS file which is then sent to the printer? If anyone could please offer me up some advice or point me in the right direction I would greatly appreciate it. So far google hasn't turned up anything solid and I am close to tearing my hair out trying to figure this out! Thank you in advance Cheers Todd |
It should be fairly easy. Create a bash script print command that uses ps2pdf and a lpr command to actually print the file. Any windows PS printer driver should work.
http://www.lesbell.com.au/Home.nsf/b...1?OpenDocument |
Quote:
Seeing that all written out that like makes total sense now. I can't believe I couldn't figure that out on my own. Thank you so much for the post, I definitely think I can work with this.. Will report back.. Thank you, thank you Cheers Todd |
Hey everyone,
So the suggestion that michaelk gave me worked like a charm - Thank you michaelk. I have tested the setup by using it to create pdf's and I now want to tackle printing to a physical printer. I have a question related to the print drivers though. It says that ps2pdf will work with virtually any postscript drivers. If that is the case, when I specify the drivers for this printer I should use the drivers for the physical printer I am printing to right? Because technically 2 sets of print drivers would have to be loaded when you add the one virtual representation of the printer because it is printing to both a virtual pdf creator AND a physical printer. But since ps2pdf can use just about any postscript drivers I should use the postscript drivers for the physical printer right? Sorry I know this is probably so confusing (at least it is for me!). I am just trying to think out loud though because trying to keep it straight in my head is hard. Thanks again guys... Cheers Todd |
Hey everyone,
So after a bunch of testing I managed to get it to work. The link that michaelk gave me was all I needed. I had to slightly modify it though to suit my purpose. This is what I did. **NOTE**: The majority of the stuff I did here I took from this link. I am in no way claiming that this was my idea, I only took what was on this page and modified it to work with what I needed. I first created the script: Code:
vim /usr/local/bin/printpdfCode:
chmod +x /usr/local/bin/printpdfCode:
[newPDF]I then restarted samba: Code:
/etc/init.d/smb restartTo upload the drivers from windows download the generic PS cups drivers found here. Code:
**NOTE**: You must create the same directory structure that windows has for its drivers:"/var/spool/samba/drivers/W32X86/3"Code:
First open the cups web manager in your browser by typing:Code:
#!/bin/shAs you can see the once the FIRST script creates the PDF we use the SECOND script to actually print the PDF to paper using the created PDF. This happens automatically. I CANNOT stress enough the importance of the lines redirecting their output to >> "pdfprint.log" - - this saved my life when things weren't working in the beginning. It works as a log file to check where things are going wrong. But with all this setup you shoud now be able to print 1 print job to both a PDF and paper at the sametime. The nice thing about this method as well is that you can specify it to go to any physical printer you want by simply changing the scripts. I know there is probably a more efficient way of doing this but this is what I got to work for me and I wanted to share it. If I am missing anything please let me know - I am writing this half asleep but wanted to get it up before I forgot. Thanks again guys Cheers |
Hey guys,
Sorry I forgot one thing. The reason that we load the Windows drivers from Windows to the linux server is because in my experience it is the easiest way of doing it. The reason we do this is so that when a new computer comes online and goes to add a printer from your samba server your Windows box will get the necessary drivers for the printer you wish to use directly from the samba server instead of you having to download them manually. One you have uploaded the drivers remember to actually add the printer to your windows box using the "Add Printer" procedure in windows Cheers Todd |
Just a few comments:
The spool files i.e. /var/spool/samba are not automatically deleted. The samba printers section automatically adds shares so it isn't necessary to add a specific share for the HP 9040. Any windows Postscript printer driver should work since it will be converted to PDF and the actual print job accomplished by the cups with the real print driver. Same setup as cups-pdf. The actual print driver is required on the linux computer. |
Quote:
You are right - sorry. There is probably a lot of of unnecessary stuff in my config files and scripts. I originally added the HP9040 share because I wanted to specify specific properties for that printer, but in a case where you do not need to specify special properties the [printer] share is enough. I see what you are saying for the /var/spool/samba now - I have to add the -r option for the [HP9040] script I wrote or else the spool files will start to pile up. Thank you for pointing that out Cheers |
| All times are GMT -5. The time now is 04:40 AM. |