Print Downloader's Name on PDF Ebook
February 26, 2009 12:09 PM   Subscribe

Is there an automated way to print a person's name on a PDF when they fill out a Web form to get it? Like, "this printed for your name here"

I want to distribute an ebook as a PDF. Rather than use some DRM scheme, I want to publish the downloader's name on the footer of the PDF.

So on the footer of every page it will say, "This printed for _____ (your name here)"

The downloader will insert their name into a Web form, their "custom" PDF will be created in the background, and then they'll get a link to download.

I know this can be done; the guys at 37signals do it with their Getting Real ebook (https://gettingreal.37signals.com/).

How can this be done? FWIW, I will be using Wordpress to manage the site and PayPal for payments. Server supports PHP and Ruby.
posted by junger to Computers & Internet (11 answers total) 2 users marked this as a favorite
 
It can be done with PHP (and some additional libraries).
posted by nitsuj at 12:11 PM on February 26, 2009


Is the ebook original in LaTeX by any chance? You could put the name in that then feed it into pdflatex.
posted by chndrcks at 12:28 PM on February 26, 2009


In sort as nitsuj suggests it is done by building a new PDF for each user. Commonly this is done by a library that let's you programatically build a PDF through the addition of its composite components (images, page, text, formatting, etc.) or through a scheme where a document is transformed from source format to pdf (e.g. xml to pdf). The XSL Formatting Objects was designed with this use case in mind.
posted by mmascolino at 12:28 PM on February 26, 2009


Does your server have Ghostscript? If so, you could store your book as a postscript file on the server, and have a very simple end of page routine that you could substitute the buyer's name in the footer. Run it through ps2pdf, and you've got a personalized book.

Alternatively, you could do something almost as described here (minus the composite bit), change the postscript to your footer text, have PHP call ps2pdf on this file, then use pdftk to add the footer as a watermark to the main PDF.
posted by scruss at 12:44 PM on February 26, 2009


Rather than constructing the PDF on the fly or starting with postscript, it's possible to fill out a PDF form and output the result. There's a quick and dirty method described here and there's some info on doing it with the Zend framework here.

The Zend stuff might allow you to put a light watermark on the page, if that wouldn't be too unpleasant.
posted by phearlez at 2:30 PM on February 26, 2009


There are several free tools available that can put a text watermark on an existing pdf. pdftk is a command line utility that is available for Linux, Windows and MacOS.
You should be able to integrate this into a web form fairly easily. (This is like the Fermat thing: it's easy but there is not enough space in this margin :-). But you should be able to find lots of code examples on the web for whatever framework you use, that will show you how to call an external programm with an argument from a web form.)
posted by mmkhd at 3:14 PM on February 26, 2009


I am sorry, pdftk can only put a pdf watermark on an existing pdf. But mbtpdfasm which is also free and multiplatform can put a text watermark in an existing pdf. (Here the only difficulty is understanding the authors english :-) The program itself is great, thoughand the english is no worse than mine.)
posted by mmkhd at 3:26 PM on February 26, 2009


Best answer: Totally do-able.

I've done this in two different forms, the most recent being a 'certificate' PDF that gets emailed to you after you fill in a form. I used PHP and fPDF with the FPDI extension. The original 'background' for the certificate is a PDF, and the name is applied, then saved as another PDF, attached to an email, and you receive it.

The other project was far more involved, with dozens of pieces of text that were filled into a PDF form after being entered on a web page form.

That being said, if you use paypal's "pay now" buttons, you do have the option of adding a 'special instruction' field into the PayPal purchasing process. Most people would use this for engravings, etc.... the point being that PayPal can pass you that data and you can then feed it to your script. (I was creating PayPal buttons last night.)

Seems like a neat project. Let me know if I can help out. :-)
posted by Wild_Eep at 5:44 PM on February 26, 2009 [2 favorites]


If your hosting setup involves Java or .Net, you can easily do this with iText/iTextSharp.
posted by Horselover Fat at 5:59 PM on February 26, 2009


Sidenote:

Hey, you're all providing excellent suggestions. If you were to streamline one of them to the point where a non-technical/end-user/Zombie type could stamp a buyer's name on a pdf by having that pdf, upon sale, automatically and instantaneously run through a script, and having that script do the requisite voodoo-- again, automatically and instantaneously--, you'd have a popular product on your hands.
posted by darth_tedious at 11:18 PM on February 26, 2009


Response by poster: Thanks for all the suggestions.

I must admit I'm closer to darth_tedious's non-technical Zombie-type than I am getting deep in PHP. (Thanks to WP's usability, I rarely do more than create a database and leave it at that)

Wild_Eep, thanks for the wonderful answer (especially integrating PayPal). Emailing the PDF may be a better solution, in itself.
posted by junger at 5:56 AM on February 27, 2009


« Older Is the greek religion still around?   |   In a community property state, if I file... Newer »
This thread is closed to new comments.