Re: Pseudo PDF Printer

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



People replying to messages on a list should reply to the list so everyone
can benifit; not that I mind you sending me private emails...

Andy Davidson said:
> Scott Taylor wrote:
>> I built a pseudo printer on my Samba server, so users can print their
>> ExHel documents (from Windoze) and receive an email with a PDF
>> attachment.
>>  However, even using a Colour PS Printer in Windows, "HP Color Laserjet
>> 5/5M PS", the PDF comes out in greyscale.
>
> That's hella cool.  Do you have example configs that you're allowed to
> share ?

Sure.  It's all on Google.

First you need a *Nix boxen with Samba, and Ghost Script
Then search Google for Print to PDF

I ended up searching a lot of things like Samba.org and used a few others
from google as well, because a lot of the docs are outdated and Samba 3.x
is  different then 2.x in a lot of ways; for example, I couldn't find a
way to store the print drivers on Samba 3.x the way I would have on 2.x. 
(if anyone has found a good doc on that I would apreciate a link)

Anyhow, after reading and trying many things, the one that helped me most
was at Digital Hermit:
http://www.digitalhermit.com/linux/printing/index.html#SECTION05020000000000000000

However, storing the documents on a directory for my users is not wise,
because my users are not all that savvy; they have a hard time
understanding that their mapped drive is a different computer and that is
why they can access their documents from any workstation in the office. =P

So: I wrote a Perl script using MIME::Lite to email the document to them.

In my smb.conf file I added the printer:

[pdf]
    comment = PDF File Generator
    path = /var/spool/samba
    printable = yes ; Makes it a printer
    guest ok = yes
; Send document to a script; %s is the print spool file %u is the user id
    print command = /usr/local/bin/printpdf %s %u
    lpq command =
    lprm command =

Those last two lines I got from Samba.org, I forget off hand why they are
needed, but they are for 3.x.

I used the HP Color LaserJet 5M/5MP PS drivers in Win2k and it works
great, outputing colour PDF documents. :)

the script that makes it work:
<bash script>
#!/bin/sh
SPDIR=/var/spool/samba
# OUTDIR=/opt/pdfdropbox # need proper access on this if you use it
# I'm going to use the users ~/ instead

# need $HOME, doesn't come with user info so we'll create it.
HOME=`grep $2 /etc/passwd|cut -d: -f6` # SedNAwk would work too

# drop the new file in the usrs ~/
ps2pdf $1 $HOME/$2.pdf

# Clean up samba spool...
rm $SPDIR/smbprn*

# Pipe the new file through our email program to attach the PDF
/usr/local/bin/mailit.pl $2 $2.pdf $HOME/$2.pdf
#
# clean up after the user (or not if you want to leave a copy there
rm $HOME/$2.pdf

# alternately we could use uuencode, but it's not the greatest
# way to attach a file anymore.
# uuencode $OUTDIR/$2.pdf $2.pdf | mail -s "Your PDF Document is ready" $2
#END
</bash script>

I'm not going to put the MIME Perl script here, that's a thing for perl
hackers, if you are one, all you need it MIME::Lite and it's simple.  Be
adventurous (google); there are amny ways to attach files to email.

One thing is wrong with this, there is no file locking, and I'm reusing
the same file name, so if someone were to print many large files, in a
row, it could get clobbered.  Already I have found it doesn't like to
create to big of a file, but that will require futher investigation.  (not
perfect, but it works great and they all love it)

Enjoy, and Good Luck.

I'm off to work on my new PalmOne thingy, new project. :)

--
Scott

-
: send the line "unsubscribe linux-admin" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Newbie]     [Audio]     [Hams]     [Kernel Newbies]     [Util Linux NG]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Device Drivers]     [Samba]     [Video 4 Linux]     [Git]     [Fedora Users]

  Powered by Linux