Advertisements
What's New

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

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
After you are done, you can now log into your machine using your DOMAIN\user credentials. Remember that the DOMAIN\ part is mandatory and that it represents the short name of your AD domain.
Step 3: Installing Samba File Server
The first step is to install the samba package. From a terminal prompt enter:
  • 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
Configuration of Samba Print Server:
  • 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
The default Samba configuration will automatically share any printers installed. Simply install the printer locally on your Windows clients.
Step 5: Creating the PDF printer
First, you’ll need to add the printer to the Samba configuration file. From a terminal open /etc/samba/smb.conf, and add the following stanza at the bottom of the configuration file:
    • [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
Save your modified smb.conf file and test it by running the testparm command, you should see it processing the various sections of your smb.conf file.
  • 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.
Step 6: Configuring Windows Clients
You should use the Windows “Add Printer” wizard to add the printer on Windows clients that will use it. Obviously, this will be a network printer, and you should be able to browse to it by finding the server and double-clicking on it to list the print queues. For a suitable driver, virtually any Postscript printer driver will do. Once the printer has been created, you can customize settings such as the paper size.
Advertisements
About BjTechNews (911 Articles)
An IT guy trying to learn everything about technology and sharing it with you all. I'm a blogger and video blogger who highlights daily news in the tech industry, promoting tips and hacks for fellow techies.

3 Comments on PDF printer on a Samba Server

  1. I am getting access denied when trying to add the printer. Domain login works just fine though…

  2. 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.

Leave a Reply

%d bloggers like this: