Error while printing

Skip Navigation LinksHome  /  Support  /  Forums  /  DynamicPDF PrintManager for .NET (v2.x)  /  Display Thread

DynamicPDF PrintManager for .NET (v2.x) Forum

 Jun 24 2015 9:11 AM
Hi!

While using following from ASP.Net code, I am getting error as follows:

Error initializing print options. Error code:998

This occurs on the following line:
PrintJob printJob = new PrintJob(Printer.Default, Server.MapPath(@"pathiknowexists" + filename));
 Jun 24 2015 4:50 PM
Posted by a ceTe Software moderator
Hello,

In your code, please try and specify the actual printer name in place of Printer.Default. The ASP.NET code runs under the IIS user account and it may not have access to the printer you are trying to print to or may have a different default printer. 

Thanks,
ceTe Software Support Team.
 Jun 26 2015 5:30 AM
Hi,

When I run my code in local mode from VS 2010, it executes and I can see the printer icon in my status bar.

PrintJob printJob = new PrintJob(Printer.Default, Server.MapPath(@"~/xxxpath/" + filename));
printJob.Print();

But when I tried the same thing after deploying this code hosted in IIS 7, I get the error:
'The default printer could not be loaded.'

Please note that specifying the printer name is not an option for me.

Thanks and regards...
 Jun 26 2015 12:04 PM
Posted by a ceTe Software moderator
Hello,

The printers are typically installed and configured for each account and a default printer might be a different printer for the internet user account or it might not have been configured correctly. Please make sure that the printer is configured correctly so that the application can access it for printing.

Also using PrintManager you can read the installed printers installed using Printer.GetLocalPrinter() method and also use the Printer.Default.Name property to retrieve the printer name. Using the GetLocalPrinter() you will be able to see what printers are installed for the internet user account and pick the correct printer to print to.

Thanks,
ceTe Software Support Team.
 Jun 13 2017 4:59 AM
hi,
I have hosted my application in server,It is getting error like "The default printer could not be loaded",Is there any other settings need to work out to work with user specified location.
 Jun 13 2017 12:14 PM
Posted by a ceTe Software moderator
Hello,

The DynamicPDF PrintManager is a server side component and can only print to the printers available to the web server where the site is hosted.

The ASP.NET code runs on the server so when you specify Printer.Default in your ASP.NET code the PrintManager tries to find the printers that are available on the server side. If a default printer is not available it will throw the error you are seeing.

On the server, the printers are typically installed and configured for each account and a default printer might be a different printer for the ASP.NET user account or it might not have been configured correctly. If you want to print on the server side, please make sure that the printer is configured correctly for the ASP.NET account so the application can access it for printing.

Also using PrintManager you can read the installed printers installed using  Printer.GetLocalPrinter()  method and also use the Printer.Default.Name property to retrieve the printer name. Using the GetLocalPrinter() you will be able to see what printers are installed for the internet user account and pick the correct printer to print to.

Thanks,
ceTe Software Support Team.

All times are US Eastern Standard time. The time now is 2:37 PM.