I have been tasked with creating a WCF service that will print a specified file to a network printer. I am using the System.Drawing method in C# to create the print method however when I run through it I keep getting the following error message:
{"Settings to access printer '\\\\UKPRINT01\\UKPRINT024' are not valid"}
I have looked online and the only advice I can find is having the printer installed locally however this isn't really a viable option for this particular WCF service. The WCF will be hosted via Windows Service, and it is being created using .net 4.0 and in Visual Studio 2012.
The code for printing method is as follows:
streamToPrint = new StreamReader(filePath);
try
{
printFont = new Font("Arial", 10);
PrintDocument pd = new PrintDocument();
pd.PrintPage += new PrintPageEventHandler(pd_PrintPage);
pd.PrinterSettings.PrinterName = @"\\UKSPPS01\UKSPPRN024";
// Print the document.
pd.Print();
}
finally
{
streamToPrint.Close();
}