views:

431

answers:

5

I'm trying to dynamically create a PDF from a background image and some text from a database.

When a user visits our site, they can click on a button to print a voucher that can be redeemed in store. The voucher consists of a background image and some text printed over the top of it; Name, Voucher Code (generated from a hash algorithm) and Email Address.

Currently, the user can print this out right away or have it emailed. However, I want to turn the voucher into a PDF so that the user can save the voucher for later.

The site is built in classic ASP, so i would need a solution that can create a PDF of the voucher image and the text from the database.

I wondered if anyone had any suggestions on how I could approach this?

Thank you.

A: 

There are some pretty nifty tools which can convert a website into a pdf.

Look at this example.

Lucas McCoy
+1  A: 

User ABCpdf

joe
A: 

One of the approach is to save the snapshot in a word-document [ it can be done using ASP ] and then use software like CutePdf, which converts the word document into PDF. Doing that, you can easily achieve your requirement.

The other approach would be, using open source libraries, which given flexibility to generate PDF documents. But that requires, a lot of understanding [ in terms of usage of the library and its API's ]

Roopesh Majeti
+1  A: 

You can create an Acrobat form using Adobe Acrobat (i.e. a PDF containing form fields), and then populate those form fields from the database. That way, your "form" PDF can have as much complex artwork etc. as you like, and you can create it in pretty much any tool you choose (Word, Illustrator, Quark, etc.). You'll need Acrobat (not just Reader) to actually create the form fields.

As for populating the form fields, there are many tools that do this, but I think the best (and certainly the cheapest - it's free) is iText or its C# equivalent iTextSharp. You can populate the fields and flatten the document (so that the fields are no longer fields) in a dozen lines of code.

See the iText site for details.

EDIT: oops, I see now that you said classic ASP, so iTextSharp may not be ideal for you unless you're prepared to make a COM wrapper for it. There are, however, other COM-based tools to do the same job. Adobe used to supply an FDF toolkit but I believe they no longer support it.

Gary McGill
A: 

I think you need to weigh this requirement carefully. Either you are going to need to buy in some additional software or just possiblly there may be away to do it for free but that'll come with some significant hassle (which in turn translates into cost).

I know of no simple free ways to acheive this in classic ASP. I've used many such sites which offer a printable "ticket", most use the "print this web page now or print the email we've just sent you" approach.

Unless you believe the download a PDF approach is so appealing to your customers that it creates a significant differentiator over your competition it might not be worth bothering.

AnthonyWJones