I have to use a 3rd party SDK that generates reports in a System.Drawing.Printing.PrintDocument format. Since my project is not a Windows Form project(it is a Web project),I need to convert this System.Drawing.Printing.PrintDocument to a PDF. I have downloaded iTextSharp and SharpPDF but they seem to create a new PDF. I have also gone through the tutorial(s) here: . My requirement is to convert the document that I already have into a PDF. Is there something that I'm missing in using these libraries? Can someone please provide a sample code to achieve this?

2 Answers

How about installing a virtual PDF printer and "print" the document? For example - , or ?

A code sample of how to print a PrintDocument, can be found here

Another possible course would be take the Graphics from the PrintDocument ((v=vs.80).aspx and look at what is proposed here -

4

you can create document by print to file in .net

exapmle : convert printDocument to XPS file , try code:

private void button8_Click(object sender, EventArgs e) { Addpage = 0; printDocument1.PrinterSettings.PrinterName = "Microsoft XPS Document Writer"; printDocument1.DefaultPageSettings.PrinterSettings.PrintToFile = true; printDocument1.DefaultPageSettings.PrinterSettings.PrintFileName = "d:\\ddd11.xps"; printDocument1.PrintController = new StandardPrintController(); printDocument1.Print(); }​ 

in future time we will get convert printDucument to pdf file .

thank you

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.