PDF printer on a Samba Server
One of the most common ways to network Ubuntu and Windows computers is to configure Samba. Within this blog I will show you how to setup Samba File Server, Samba Print Server, and create a PDF creation script which will do the job of turning Postscript into an Adobe Acrobat file. The bulk of the work is done by the ps2pdf program, which is part of the Ghostscript package.
Step 1: Adding Ubuntu to Active Directory Domain (this was done with Windows Server 2003)
- I used Likewise Open, which is a free open source application that joins Linux, Unix and Mac machines to Microsoft Active Directory and securely authenticates users with their domain credentials. It’s FREE!!! π
- Likewise Open Features (some)
- joins non-Windows systems to AD domains in a single step from the command line or from a GUI
- supports multiple forests with one-way and two-way cross forest trusts
- caches credentials in case your domain controller goes down
- involves no AD schema changes
- Likewise Open Features (some)
So back to Step 1:
So installing it is pretty easy, open a Terminal command or open a SSH session to your server:
at the command prompt enter: sudo aptitude install likewise-open-gui
once the package is downloaded and install on the server, it’s time to join the machine to your AD.
Step 2: Adding your computer to Active Directory Domain
Within your terminal session or putty session type in this commands:
- sudo domainjoin-cli join fqdn.of.your.domain Administrator
- sudo update-rc.d likewise-open defaults
- sudo /etc/init.d/likewise-open start
- sudo apt-get install samba
That’s all there is to it; you are ready to configure Samba to share folders.
Configuration of Samba File Server:
The main Samba configuration file is located in /etc/samba/smb.conf. The default configuration file has a significant amount of comments in order to document various configuration directives.
- First, edit the following key/value pairs in the [global] section of /etc/samba/smb.conf:
- workgroup = your.domain.name
- security = user
- security parameter is farther down in the [global] section, and is commented by default.
- Create a new section at the bottom of the file, or uncomment one of the examples, for the directory to be shared:
- [pdf_share]
- comment = PDF share folder
- path = /srv/samba/pdf
- browsable = yes
- guest ok = yes
- read only = no
- create mask = 0755
- Now that Samba is configured, the directory needs to be created and the permissions changed. From a terminal enter:
- sudo mkdir -p /srv/samba/pdf
- sudo chown nobody.nogroup /srv/samba/pdf/
- Finally, restart the Samba services to enable the new configuration:
- sudo restart smbd
- sudo restart nmbd
Now, you should be able to go to a Windows client and browse to the Unix share directory.
Step 4: Configuring the Samba Print Server
- If you have been following the blog, you should already have the Samba installed. If not, from a terminal enter:
- sudo apt-get install samba
- Open the Samba configuration file, which is located here: /etc/samba/smb.conf. Β The workgroup and security section of the [global] attribute should of been changed during the process of Step 3.
- In the [printers] section change the guest ok option to yes:
- browsable = yes
- guest ok = yes
- After editing smb.conf restart Samba:
- sudo restart smbd
- sudo restart nmbd
- [pdf]
- comment = Print to create PDF
- printing = LPRNG
- path = /var/spool/samba
- printable = yes
- print command = /usr/local/bin/printpdf %s %u %H “%J”
- %s = the pathname of the spool file
- %u = the username for this service
- %H = the home directory for the user
- %J = the print job name, as sent by the client, this is usually the document’s name or title
- The Script!
- create a file within nano or vi (editor’s for unix) named printpdf and enter this:
- #!/bin/sh
- # Shell script to print to PDF files
- # Parameters $1 = spool file (smbprn . . . )
- # $2 = user name
- # $3 = user home directory
- # $4 = print job name
- OUTDIR =/srv/samba/pdf
- echo Converting $1 to “$4” for user $2 in $3 >> pdfprint.log
- ps2pdf $1 “$OUTDIR/$4.pdf”
- rm $1
- save either of the scripts above as /usr/local/bin/printpdf, and make it executable with the command sudo chmod +x /usr/local/bin/printpdf.
- create a file within nano or vi (editor’s for unix) named printpdf and enter this:
I am getting access denied when trying to add the printer. Domain login works just fine though…
Which printer driver would you prefer?
I use “HP Color LaserJet 2800 Series PS” on two Windows 8 64 bit Units. These are working just fine there.
But I have lot’s of trouble with a Windows 8 32 bit system. However the same but 32 bit driver – I don’t have another explanation – inserts a blank/white second page. This is pretty much annoying.
Have tried using Post Script driver?