Print to PDF using office stationary with Samba

When sending quotes via email my useres first printed them on office stationary. After that they went to the printer, put the sheets into the scanner and made an enormous big pdf that they sent to their customers.

A quick, easy and quite common solution is to set up a samba printer that accepts postcript jobs and converts them to pdf. This solution can also be tweaked in order to combine the output with another pdf that carries the company logo, adress, a watermark or whatever you like.

The wole magic comes from a package called pdftk which is responsible for merging the 2 documents together. Well and a little modification to sambas smb.conf

So install pdftk using "apt-get install pdftk "

And modify you smb.conf 

 [PDF-Stationary]
    comment = PDF Drucker mit Briefpapier
    path = /srv/smb/pdf
    printable = yes
    guest ok = yes
    create mask = 0777
    use client driver = yes
    
    print command = gs -dNOPAUSE -dBATCH -q -sDEVICE=pdfwrite -sOutputFile="%s.tmp.pdf" "%s"; \
    pdftk "%s.tmp.pdf" burst output "%s"PAGE%02d; \
    for N in "%s"PAGE*; \
    do pdftk briefpapier.pdf background $N output $N.TMP; \
    done; \
    pdftk "%s"PAGE*.TMP cat output "%s.pdf"; \
    rm "%s"PAGE*; rm doc_data.txt; \
    rm "%s"; rm "%s.tmp.pdf"; \
    mkdir "/srv/smb/Home/%u/pdf"; \
    chmod 777 "/srv/smb/Home/%u/pdf"; \
    mv "%s.pdf" "/srv/smb/Home/%u/pdf/%s.pdf";
    lpq command =  

This modification requires a pdf file containing the office stationary called briefpapier.pdf placed in /srv/smb/pdf in my case.
The resulting pdf will be placed in a directory called pdf located in each users home directory.

When connecting to the printer from windows then choose some HP Color Laserjet Printer but take care that it is a PS-Printer.

Many thanks to nkadesign.com who posted a similar solution.

If you take a look at the man pages of pdftk you'll notice that there's an easier solution  than splitting the printjob into its pages and recombine them later. The reason why Icouldn't use the background option of pdftk was that M$ Word seems to place a white rectangle around every pages which overlaps the office stationary...

Happy printing