Does anyone know if the following is possible and if so what the best way of doing it is for free?
I am generating a PrintDocument in a project I am currently workin
The System.Drawing code for a PrintDocument can be reused to generate a PDF document with ABCpdf .NET. See the System.Drawing example...
You're in a world of hurt if you think you're going to run the "same code" that deals with printers in both a forms app and an ASP.NET app.
You might be in luck, however, as it appears that PDFsharp + MigraDoc might be able to do this for you.
I think you will find there is not any tools that will take a PrintDocument as input and render a PDF as output. The only way to do what you want is to "print" the PrintDocument to a "PDF printer driver" that will generate PDF. Basically a virtual printer that will generate PDF instead of printing the actual output. There are a plethora of products on the market for that. A couple that are cheap and widely used are as follows:
You would have to use a 3rd party component in order to generate the PDF. The following article has some links to some such components: Generating PDF Files from .Net
There are several ports of iText for .NET (A very popular open-source PDF library for Java).
http://www.ujihara.jp/iTextdotNET/en/
You really should be looking at iTextSharp (it is mentioned on the iText.NET page recommended earlier)
http://itextsharp.sourceforge.net/
PrintDocument is meant for Windows Forms applications but is up and coming in SilverLight, see this video... http://silverlight.net/learn/videos/all/printing-api-basics/
If you wish to continue with the PrintDocument and a web application, I think SilverLight 4 (which is beta right now) is the only way to go, or your going to have to have a lite weight windows form application installed locally for the end user that maybe uses web services.
iTextSharp is a great tool for generating PDFs with .NET on the Internet. I highly recommend it; I've used iText with Java...and have been using iTextSharp for the past few years.