Generating PDFs with Alambic
Novell Cool Solutions: Feature
By Peter Van den Wildenbergh
Digg This -
Posted: 17 May 2006
License and Disclaimer
See http://www.opencontent.org/opl.shtml for the full software and documentation license for this solution. Basically, you can copy, redistribute, or modify this "how to," provided that modified versions, if redistributed, are also covered by the OpenContent License. Please e-mail a copy of your modified document to pvdw <@> criticalcontrol <.> com. Use this document at your own risk; it comes with no warranty. See the OpenContent License mentioned above.
Although everybody has access to OpenOffice (http://www.openoffice.org) most of the users I deal with are stuck with a word processor, spreadsheet or any other application that is not capable of producing a PDF version of their documents without external tools.
This shortcoming has been recognized by many, both commercial and non-commercial solutions are available. As a die-hard Linux fan I went with a GPL'ed solution that can be tweaked if needed.
After choosing for the Alambic solution (http://alambic.iroise.net/) I ran into some problems getting things going the lazy way, read installing from rpm/binaries. With a lot of help from the creator and maintainer of Alambic I was able to get this thing installed from source. In the end, Alambic was update from version 1.0.2 to 188.8.131.52 to get it working on a SUSE 10. Ever thought about contacting the lead developer of Adobe to fix a PDF problem? My implementation of Alambic was yet another true Free and Open Source Software experience, it takes its time, but the reward is priceless. Thank you Mathias Herberts.
Installing Alambic on a SUSE 10
I assume you got a good working properly installed SUSE 10 with the "C/C++ Compiler and Tools" available. In order to get Alambic compiled from source you will need openssl-devel. Install via YaST if needed. Other packages you need like, Apache, CUPS and ps2pdf should be installed on your system with a normal SUSE 10 deployment. The name of the server used in this example is "linuxservices".
Putting the system in place
Download Alambic and unpack it in a convenient spot. Open up a super user console and type:
cd /usr/local/src wget http://alambic.iroise.net/Alambic-184.108.40.206-src.tar.gz tar -zxf Alambic-220.127.116.11.-src.tar.gz cd Alambic-18.104.22.168 less README make
You should see something like this flying by on the screen:
gcc -O9 -static -Dlog=AlambicLog -c alambic.c gcc -O9 -static -Dlog=AlambicLog -c cf.c gcc -O9 -static -Dlog=AlambicLog -c usercf.c gcc -O9 -static -Dlog=AlambicLog -c log.c gcc -O9 -static -Dlog=AlambicLog -c smtp.c gcc -O9 -static -Dlog=AlambicLog -c locale.c gcc -O9 -static -Dlog=AlambicLog -o Alambic alambic.o cf.o usercf.o log.o smtp.o locale.o -static -lcrypto log.o: In function `ouropenlog': log.c:(.text+0x2dd): warning: Using 'gethostbyaddr' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking log.c:(.text+0x237): warning: Using 'gethostbyname' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking log.c:(.text+0x1f7): warning: Using 'getprotobyname' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking log.c:(.text+0x1e2): warning: Using 'getservbyname' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking log.c:(.text+0x283): warning: Using 'getservbyport' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking strip Alambic
Pick a spot to put the binary and create a bin, etc and log directory.
mkdir /usr/local/alambic cd /usr/local/alambic mkdir bin etc log
Copy the newly created Alambic binary in the bin directory.
cp /usr/local/src/Alambic-22.214.171.124/Alambic ./bin/
Copy the Alambic.cf and Alambic.ppd files to the etc directory.
cp /usr/local/src/Alambic-126.96.36.199/Alambic.cf ./etc/ cp /usr/local/src/Alambic-188.8.131.52/Alambic.ppd ./etc/
Change into the /usr/local/alambic/etc directory and adjust the Alambic.cf file to reflect your environment.
cd etc vi Alambic.cf
Lang=en WorkDir=/srv/www/alambic # linuxservices is a internal resolvable name URLPrefix=http://linuxservices/alambic/ UserCf=builtin:/usr/local/alambic/etc/users PDFGen=/usr/bin/ps2pdf -dAutoFilterColorImages=false -dColorImageFilter=/FlateEncode %s %s LogFile=/usr/local/alambic/log/alambic.log # Can be an IP address or name should resolve to your mail server. SMTPHost=smtp SMTPPort=25 #Set max file size that gets e-mailed back to a user to 10 megabytes - That's plenty SMTPMax=10485760 MailFrom=pdf-creator@linuxservices KeepBadPS=false
Now we need to tweak the CUPS server. By default this service is running on SUSE 10.
cd /usr/share/cups/model/ ln -s /usr/local/alambic/etc/Alambic.ppd Alambic.ppd cd /usr/lib/cups/backend ln -s /usr/local/alambic/bin/Alambic Alambic
Restart CUPS and register the PDF printer in CUPS.
/etc/init.d/cups restart lpadmin -p Alambic -v Alambic:/usr/local/alambic/etc/Alambic.cf -m Alambic.ppd -E
You may want to take a peek via a browser to see everything is there.
Note: To set SUSE to the standard default settings of CUPS:
Change RunAsUser Yes to RunAsUser No.
Change in <Location /admin> the AuthType to AuthType Basic
This will enable you to do administrative tasks via the browser. Use root to log in when promted.
I installed Apache2 on this SUSE 10 server, the instructions below assume your working on a untweaked Apache2 configuration as it comes with the default install.
Unlike CUPS, the Apache server is not started by default on your SUSE 10. Fire up YaST and go to System -> System Services (Runlevel) and enable the apache2 service if needed.
cd /etc/apache2/vhosts.d vi linuxservices.conf
<VirtualHost *:80> ServerName linuxservices DocumentRoot /srv/www/alambic/htdocs/ <Directory /srv/www/alambic/htdocs> AllowOverride None Options Indexes Order Allow,Deny Allow from all </Directory> </VirtualHost>
Before restarting Apache make sure the /srv/www/alambic/htdocs directory exists.
usermod -g www lp cd /srv/www mkdir alambic/htdocs -p
Restart Apache, if it's running already you may want to do it gracefully.
apache2ctl -k graceful
Checking 2 more got'chas
A local firewall is enabled after a standard SUSE install, make sure your server is reachable on port 631 and 80. In a real world situation you also need to make sure your mail server defined in Alambic.cf is configured to relay e-mail coming from the server.
Last but not least.
To finish up our setup we need to go back to the /usr/local/alambic/etc directory and create a users file.
This file takes the format username:e-mail
cd /usr/local/alambic/etc vi users
Make sure the last line has no username just a colon and an e-mail address.
This is the e-mail address used when an unknown user tries to generate a PDF.
If you want to test locally use :root@localhost as the only one line in the users file
The user file should be readable by the user lp, chmod 644 will do.
Open up a browser and browse to your new print-server. Try printing a test page, keep on eye on your e-mail. If things don't go like advertised you may want to take a peek in /usr/local/alambic/log/alambic.log also the CUPS log files in /var/log/cups may give you an indication as to what is wrong. Also try the Apache set-up by altering the SMTPMax value in the alambic.cf file
Set it to 10, print a test page and browse to http://linuxservices/
Printing from XP desktops
Those users who are unfortunate and stuck with a XP desktop can benefit from this too.
Setting up windows printing... (Bare with me here, if you know an easier way let me know!)
First of all copy the Alambic.ppd file to C:\WINDOWS\system32\spool\PRINTERS
Open up a browser (http://www.getfirefox.com) and browse to:
Download the Adobe Universal PostScript Windows Driver Installer of your choice.
After clicking twice on a red download button save "winsteng.exe to disk.
Close the browser and launch winsteng.exe
Click the "Next >" and "ACCEPT" buttons when they appear. When asked how your printer is connected select "It is connected to your network (Network Printer)" and click "Next >"
Next screen asks you to enter a Network Path. If you followed the naming used in this document type:
and click "Next >"
When prompted with 'an error' click "Yes"
On the next screen, click "Browse..."
And browse to the "C:\WINDOWS\system32\spool\PRINTERS" directory.
Pick the Alambic 184.108.40.206 driver and hit the "OK" button.
Back at the "Select Printer Model" screen hit "Next >"
Pick what you want on the "Printer Information" window and "Next >" again.
Ready to Install?
It may take a few seconds, but in the end you should see :
I selected "No" before hitting "Next >" for the last time. Then I unselected the ReadMe thingie and hitted "Finish" on the final screen.
Time to show off
Time to test, keep a browser open for http://linuxservices:631. When printing to the Alambic printer it will tell you which username is used, handy for populating the "users" file with e-mail addresses.
Print a test page from windows. I verified it via a FireFox browser on http://linuxservices.
Maintaining the users file in a 50+ people environment would be a boring time consuming task.
Having a script that pulls the e-mail address of a user out of a LDAP directory, or at least populating the file automagically over-night is desirable... Maybe tomorrow, if I got time.
Although there are other FOSS alternatives, Alambic doesn't require Java or Samba like some of the alternatives. Everybody in the company can now generate PDFs without adware () without having to send their sensetive documents over the internet (http://www.ps2pdf.com) and without paying for Acrobat Writer on all the desktops.
This software is designed to produce PDF files in a heterogeneous network by providing a PDF printer on the central fileserver.
Yet Another Free Pdf Composer
Imagine you need a PDF-printer-like tool, which is able to generate PDF-files from documents, you want print out of your applications on your local machine. There are plenty of solutions out there on the web, which can do this for you. Now imagine you need a PDF-printer to be shared in your network, which is able to generate PDF-files from documents, the network users print out of their applications. You'll find some free solutions, which can make this. Further imagine, you want this PDF-printer automatically to apply the letterhead template of your company to the first page, apply the company-logo to all further pages, append a ?Terms and Conditions" page to all printed documents, apply some ?Watermark Graphic" on all pages to copy-protect your documents, encrypt the document to protect it from unwanted manipulation and automatically mail the document to the user, who initiated the print-job.
For Windows only:
About the Author
Peter Van den Wildenbergh is a Senior Linux Administrator and a long-time Linux advocate. He specializes in integrating Linux solution in existing environments and can be reached at: pvdw <@> criticalcontrol <.> com.
Novell Cool Solutions (corporate web communities) are produced by WebWise Solutions. www.webwiseone.com