We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Problem printing to network printer from web server

Hi there,

We have a web app that needs to pick up documents from the network and send them to one of a number of network printers.

This works fine, when the app is running locally, but doesn't work when published to the web server because there are no printers installed on the server.

I've tried using UNC paths to the printer, e.g. @"\\PrintServer02\Printer01" but get the message:

Settings to access printer '\\PrintServer02\Printer01' are not valid.

Our operations people don't want to install printers or printer drivers on the web server, so that's not an option, unfortunately.

Is there any other way to do this?

Many thanks in advance,


Hi Paul,

Thanks for your inquiry. Please use the code mentioned in the following article to be able to print a word processing document from an ASP.NET using Aspose.Words and the XpsPrint API:

I hope, this helps.

Best regards,

Hi Awais,

Thanks for the suggestion.

I've downloaded the code and plumbed it into my project, but I get the following error when trying to use the Xps API:

Webpage error details

User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; GTB7.5; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E; InfoPath.3)
Timestamp: Tue, 27 May 2014 15:10:56 UTC

Message: Sys.WebForms.PageRequestManagerServerErrorException: The printer driver is unknown
Line: 938
Char: 13
Code: 0

Any ideas?

It looks to me as though you can't print to a network printer without having the drivers installed on the server first, which is a shame as our infrastructure people are adamant that they will not install printer drivers on a web server (understandable, I guess!).



PS. the error occurs when I try to print from both the server (Windows 2008 R2) AND my development PC (Windows 7). So perhaps there's a pre-requisite for the XpsPrint API to work?

Hi Paul,

Thanks for your inquiry. Please make sure that you have rights to print on this printer and it is accessible. You can try using the following code for testing. This code does not use Aspose.Words at all. So if it will not work, the problem is somewhere on your side.
PrintDocument doc = new PrintDocument();
doc.PrinterSettings.PrinterName = @"\\printername";
doc.PrintPage += Doc_PrintPage;
private void Doc_PrintPage(object sender, PrintPageEventArgs e)
e.Graphics.DrawImage(Image.FromFile(@“Common\test.jpg”), e.MarginBounds.Left, e.MarginBounds.Top);
This code just prints an image.

Best regards,