Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use a System.Drawing.Printing.PrintDocument to generate a PDF in memory

Tags:

c#

asp.net

pdf

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 working on and displaying a print dialog box so a user can choose which printer they want to use etc. The is currently a windows form application and if a user wants to print to a PDF they can select to print to CutePDF or something similar.

However I am now putting a ASP.Net web frontend on the application and want to use the same code to generate the PrintDocument but want to print it to a PDF on the fly and serve it up via the Response stream in the format of a PDF download.

So my question is....How can I use the current PrintDocument and generate a PDF in memory from it??

Thanks

like image 851
MarkB29 Avatar asked Jan 04 '10 20:01

MarkB29


1 Answers

The System.Drawing code for a PrintDocument can be reused to generate a PDF document with ABCpdf .NET. See the System.Drawing example...

like image 76
AffineMesh Avatar answered Oct 30 '22 13:10

AffineMesh