I am writing a code in c# that prints PDF programmatically using printer drivers. Sometimes, it is shown a pop up that requires user input, e.g.
The toner is about to be exhausted, continue? YES - NO
and the printer doesn't print until the user clicks. This code runs on a server, so no one can go and click. Is there a way to overcome this problem, without knowing all the possible questions (different printers). I use this code to print, I block printing until previous document is printed:
process.StartInfo.FileName = filePath;
process.StartInfo.Arguments = "\"" + printerName + "\"";
process.StartInfo.UseShellExecute = true;
process.StartInfo.CreateNoWindow = true;
process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
process.StartInfo.Verb = "PrintTo";
process.Start();
var server = new PrintServer();
try
{
int numberOfJobs = server.GetPrintQueue(printerName).NumberOfJobs;
while (numberOfJobs == 0)
{
numberOfJobs = server.GetPrintQueue(printerName).NumberOfJobs;
}
while (numberOfJobs > 0)
{
numberOfJobs = server.GetPrintQueue(printerName).NumberOfJobs;
}
retVal = true;
}
catch
{
retVal = false;
}
finally
{
process.Kill();
}