I am developing an automated printing application, in which I would like to get selected print color of a print job printed by a user.
The problem is that it always returns a color print if I select a black and white print from print dialogue.
I have tried OutputColor
from PrintTicket
or PrintCapabilities
but both are returning a Color print whether I select Black and White from print dialogue.
Here is my code how I am getting it from PrintSystemJobInfo
:
Form1 f = form as Form1;
PrintSystemJobInfo job = e.JobInfo;
if (job == null) return;
f.UpdatePrintInfoList(job, e);
if (job.IsSpooling)
{
job.Pause();
pausedJobs.Add(new PausedJob(e.JobID));
}
else if (job.IsPaused)
{
PrintQueue pq = job.HostingPrintQueue;
pq.Refresh();
PrintJobSettings pjs = pq.CurrentJobSettings;
PrintTicket pt = pq.UserPrintTicket;
PrintCapabilities pc = pq.GetPrintCapabilities();
string outputColor = string.Empty;
if (pc.OutputColorCapability.Contains(OutputColor.Color))
{
outputColor = "Color";
}
else if (pc.OutputColorCapability.Contains(OutputColor.Grayscale))
{
outputColor = "Grayscale";
}
else if (pc.OutputColorCapability.Contains(OutputColor.Monochrome))
{
outputColor = "Monochrome";
}
else
{
outputColor = "Unknown";
}
PrinterSettings ps = new();
ps.PrinterName = printer;
string jobDetails = string.Format(
"Job Status: {0}\n" +
"Printer: {1}\n" +
"No. of Pages: {2}\n" +
"Output Color (PrintTicket): {3}\n" +
"Output Color (PrintCapabilities): {4}\n" +
"\nWould you like to continue printing?",
"Paused",
printer,
job.NumberOfPages,
pt.OutputColor,
outputColor);
}
I am developing an automated printing application, in which I would like to get selected print color of a print job printed by a user.
The problem is that it always returns a color print if I select a black and white print from print dialogue.
I have tried OutputColor
from PrintTicket
or PrintCapabilities
but both are returning a Color print whether I select Black and White from print dialogue.
Here is my code how I am getting it from PrintSystemJobInfo
:
Form1 f = form as Form1;
PrintSystemJobInfo job = e.JobInfo;
if (job == null) return;
f.UpdatePrintInfoList(job, e);
if (job.IsSpooling)
{
job.Pause();
pausedJobs.Add(new PausedJob(e.JobID));
}
else if (job.IsPaused)
{
PrintQueue pq = job.HostingPrintQueue;
pq.Refresh();
PrintJobSettings pjs = pq.CurrentJobSettings;
PrintTicket pt = pq.UserPrintTicket;
PrintCapabilities pc = pq.GetPrintCapabilities();
string outputColor = string.Empty;
if (pc.OutputColorCapability.Contains(OutputColor.Color))
{
outputColor = "Color";
}
else if (pc.OutputColorCapability.Contains(OutputColor.Grayscale))
{
outputColor = "Grayscale";
}
else if (pc.OutputColorCapability.Contains(OutputColor.Monochrome))
{
outputColor = "Monochrome";
}
else
{
outputColor = "Unknown";
}
PrinterSettings ps = new();
ps.PrinterName = printer;
string jobDetails = string.Format(
"Job Status: {0}\n" +
"Printer: {1}\n" +
"No. of Pages: {2}\n" +
"Output Color (PrintTicket): {3}\n" +
"Output Color (PrintCapabilities): {4}\n" +
"\nWould you like to continue printing?",
"Paused",
printer,
job.NumberOfPages,
pt.OutputColor,
outputColor);
}
Share
Improve this question
edited Nov 20, 2024 at 20:49
SoftSol
asked Nov 20, 2024 at 20:42
SoftSolSoftSol
4664 silver badges13 bronze badges
0
1 Answer
Reset to default 0The screen shot is from Chrome (or other Chromium -based browser), and Chrome has its own built in print management. The settings chosen here are not visible to the Windows print system. Instead, the page is sent to the Windows print driver for spooling as basic document with the appropriate settings pre-rendered. The Windows print driver may even override a color selection and still force black and white.
So what's going on is Chrome is rendering either Color or Black & White data to the Windows print driver. The Windows print driver will typically be in one of three modes:
- Automatic. This option tries to (!) detect color or black based on the rendered data or document to determine black and white or color, and this information can be used for toner selection by the printer and also for accounting (and billing) by management software.
- Color. This option always renders color. But it still seems to work, because Chrome has already pre-filtered colors down to grayscale.
- Black & White/Grayscale. This option only prints black and white, and may cause your document to come out black and white, even if you both have a color and selected color in Chrome.
Your C# code then picks up the settings from the Windows print spooler, rather than from Chrome. If you want to see the options in Chrome the same way the C# code does, you need to click the little Print using system dialog...
link.