The starting point
This project started at work when my company bought a license for a PDF factory. For those who don't this type of software, it allows you to create a PDF document from any application which can print. Thus you can convert any document type to a PDF very easily. The main benefit as far as I'm concerned is that the PDF files can be viewed by anyone via a (free) PDF viewer and if required the user cannot modify those PDF files as well which can be important if your documents are contracts for instance. Moreover the user does not need to install the application used to produce the document in the first place. Another benefit is that PDF documents are less prone to be infected with viruses as would Microsoft Office documents for example. It is generally safer to send PDF files via email than Microsoft Office documents. I personally do not accept any attachments with this kind of documents.
Right, now that you know what I'm talking about, I then thought that a free alternative to the purchased PDF factory must exist out there. I also wanted the solution to be held on a server so that installation requires minimum fuss on each client. As you would expect I turned to Linux to fill my need and found one almost immediately.
Solution requirements
PDF factories are basically virtual printers that are managed by CUPS and published by Samba to the Windows clients. On the client side the same drivers are used for all my factories. On the server side I have written a special script for each printer. There is nothing stopping you creating your own script to fill your need in the same way I have done. All the programs that will be required are free to use and based on Linux even if client machines will be running Microsoft Windows!
- The server
So first you need a server running Linux. In my case this will be Gentoo then! If you allocate one machine for the job (or even better a virtual machine using Xen of course) you should install a bare minimalistic kernel. Yes this means a console only server. I know that for some this is going back into the past but graphic just adds too much overheads. You can still manage your machine via SSH anyway if you really want a GUI working environment. - uuenview
This encoder can be found here. For those with Gentoo, this is more simple:emerge uudeview
- CUPS
Next you need to install CUPS. This is the printer server that will held our PDF factory. In my case I simply did:emerge CUPS
Then edit /etc/cups/mime.convs file and uncomment application/octet-stream line. You need also the Windows printer drivers that will be installed automatically onto your clients. For that purpose create the folder /usr/share/cups/drivers and copy these files into it. Those drivers are the default one made available on CUPS web site. I would thus recommend you to head there and pick up the lastest version. Finally add cupsd to your default runlevel. In Gentoo:rc-update add cupsd default
- Samba
In order for our Windows clients to talk to the Linux server and enumerate our printers we also need to install Samba next.emerge samba
My configuration file is available here. You should tailor it to suit your needs. Next create the folder /etc/samba/drivers. If you want you can make sure you can access Samba web setup interface to make things easier. Otherwise you can still use the command line to publish CUPS printers via Samba. Finally add Samba to your default runlevel:rc-update add samba default
To export printers to Samba using the web interface simply click Export to Samba button. Otherwise type the following:cupsaddsmb -H localhost -h localhost -v -U root -a
After exporting printers you should always restart your samba server./etc/init.d/samba restart
Remember you can always test your Samba configuration by running testparam. - mail system
I think this is the more tricky component to install. One of my PDF factory uses sendmail. You can change the mail agent in its configuration file if your system is not setup exactly like mine. Below is how I installed sendmail of my server:- emerge -C mailx, mailx-support, ssmtp
- emerge postfix, nail (need net USE flag)
- In /etc/bash/bashrc add
export MAIL="${HOME}/.maildir/"
- In /etc/nail.rc add
set newfolders=maildir
- Run newaliases to create aliases.db file in /etc/mail
- Add postfix to default runlevel
- cups-pdf
My backend scripts are based on cups-pdf which must be installed on our server.emerge cups-pdf
This will install the following:- cups-pdf in /usr/libexec/cups/backend.
- PostscriptColor.ppd in /usr/share/cups/model.
- Move cups-pdf to /usr/bin. Make sure to set its attributes to +rwx for root only.
- Modify /etc/cups/cups-pdf.conf to something similar to my own config file.
- Copy procconfig.sh to /usr/bin/ folder. Changes its attributes to +rx for all (i.e. ugo).
Installing Print To PDF Virtual Printer
This PDF factory will create the PDF file in a user folder on the server that can be access in the Windows client via Samba.
To install this factory follow the next steps:
- Copy printtoPDF.conf to /etc/cups/ folder.
- Copy printtoPDF.sh to /usr/libexec/cups/backend/ folder. This is the backend shell script that will called by CUPS. Don't forget to change its attributes to +rwx for root!
- Copy printtoPDF.ppd to /usr/share/cups/model/ folder.
Next use CUPS web administration to add the printer by clicking Add Printer. Select make as Postscript and model as Print To PDF Virtual Printer.
Installing Mail Back PDF Virtual Printer
This PDF factory will email the resulting PDF file to the user.
- Copy mailPDF.sh to /usr/libexec/cups/backend/ folder and make it +rx for all.
- Copy mailPDF.conf to /etc/cups/ folder.
- Copy mailPDF.ppd to /usr/share/cups/model/ folder.
- Copy pstopdf to /usr/libexec/cups/filter/ folder and make it +rx for all.
Next use CUPS web administration to add the printer by clicking Add Printer. Select make as Postscript and model as Mail Back PDF Virtual Printer.
Using my PDF factories
On a Windows client machine browse the network and select the server and then display the printers made visible by Samba. Right click a printer and install it. That's it. You can now convert any document to a PDF file by selecting the appropriate printer in the Print dialog box.