Print pdf document from on the server


I am trying to print a pdf document from On my Windows Vista 7 it works ok, but on the Windows 2008 Server, nothing is printed and it does not throw an exception.

This is the sourcecode:

PdfViewer viewer = new PdfViewer();
string strPath = Server.MapPath("test.pdf");

viewer.AutoResize = true; //print the file with adjusted size
viewer.AutoRotate = true; //print the file with adjusted rotation
viewer.PrintPageDialog = false; //do not produce the page number dialog when printing

//create objects for printer and page settings and PrintDocument
System.Drawing.Printing.PrinterSettings ps = new System.Drawing.Printing.PrinterSettings();
System.Drawing.Printing.PageSettings pgs = new System.Drawing.Printing.PageSettings();

System.Drawing.Printing.PrintDocument prtdoc = new System.Drawing.Printing.PrintDocument();

ps.PrinterName = "\\MyServer\Myprinter";

//set PageSize (if required)
pgs.PaperSize = new System.Drawing.Printing.PaperSize("A4", 827, 1169);
pgs.Margins = new System.Drawing.Printing.Margins(0, 0, 0, 0);

//print document using printer and page settings
viewer.PrintDocumentWithSettings(pgs, ps);

//close the PDF file after priting

thx for your help

br, Michael

Hi Michael,

Are you trying to print the PDF document on the client end using ASP.NET application? I would just like to inform you that you can’t print the PDF file on the client end. Aspose.Pdf.Kit can only print the PDF file on the server end when used in ASP.NET application; or it can print on any machine if it is a Windows From application.

I hope this helps. If you think I haven’t understood your requirement clearly or you have some more questions, please do let us know.

The document should get printed on the server.

nr, Michael

Hi Michael,

We need to test this issue at our end. Please spare us some time and you’ll be updated with the results accordingly.

We’re sorry for the inconvenience.


Do you have any directions for us, we need to inform our client?

best regards,


Hi Michael,

I’m sorry to inform you that we’re still investigating this issue at our end; I’m afraid, we’re unable to advise you anything at the moment. Please spare us some time so we could better understand the issue and you’ll be updated accordingly. However, in the meanwhile can you please share that which version of .NET Framework you’re using at your end?

We’re sorry for the inconvenience.

Hi Michael,

I have tested this issue at my end on Windows Server 2008 using .NET Framework 4.0 and latest version of Aspose.Pdf.Kit for .NET (4.6.0), but I couldn’t notice any problem; the PDF file is printed successfully. Can you please download the latest version and try with that?

If you still find any issues or have some more questions, please do let us know.

Error 1 The type or namespace name ‘PdfViewer’ could not be found (are you missing a using directive or an assembly reference?) Plz help me.

Hi Ankit,

First of all, please add reference to the Aspose.Pdf.Kit for .NET DLL.
Secondly, either use the class name with the complete namespace i.e. Aspose.Pdf.Kit.PdfViewer, or import the namespace and then use PdfViewer class, just like any other .NET assembly.

I hope this helps. If you have any further questions, please do let us know.