Reputation: 2540
I am trying to print to an unusual printer (BIXOLON SPP-R200III) from a C# WPF application. The width of this printer's paper roll is 58mm, as measured with a ruler and as shown in the Windows Print Dialog box:
However, when I try to connect to this printer and interrogate its capabilities via the System.Printing
APIs in the .NET Framework, I get a different paper width.
The following code enumerates print queues and finds the correct one:
const string printQueueName = @"BIXOLON SPP-R200III";
PrintServer printServer = new PrintServer();
PrintQueue printQueue = null;
PrintQueueCollection printQueues = printServer.GetPrintQueues();
foreach (PrintQueue queue in printQueues)
{
if (String.Equals(queue.FullName, printQueueName, StringComparison.CurrentCultureIgnoreCase))
{
printQueue = queue;
break;
}
}
This code interrogates its capabilities:
PrintTicket defaultTicket = printQueue.DefaultPrintTicket;
PrintCapabilities printCapabilities = printQueue.GetPrintCapabilities(defaultTicket);
double pageWidth = (printCapabilities.OrientedPageMediaWidth.Value / 96.0) * 25.4;
But the result, pageWidth
is 48.047 and not 58mm as expected!(PrintCapabilities.OrientedPageMediaWidth
is 181.59496062992128.)
I also tried looking at the default print-ticket structure itself but printQueue.DefaultPrintTicket.PageMediaSize.Width
has the same value of 181.59496062992128.
Finally, I tried to use the System.Windows.Controls.PrintDialog
with the following code:
PrintDialog printDialog = new PrintDialog();
printDialog.PrintQueue = printQueue;
printDialog.ShowDialog();
double pageWidth = (printDialog.PrintTicket.PageMediaSize.Width.Value / 96.0) * 25.4;
And I got the same result.
Why is this? Why do these widths not match? Am I converting from dots to millimetres incorrectly? Am I completely misunderstanding printer capabilities?
What is the right way to find the paper size supported by a printer, like it is shown in the screenshot at the top of this question?
Upvotes: 0
Views: 1438
Reputation: 1668
Because there is so called "imageble area", which is always smaller than the physical dimensions of the sheet.
Probably, your printer cannot print at the very edge of the sheet.
You can make sure by inspecting the PrintCapabilities.PageBorderlessCapability Property
.
See this link: https://msdn.microsoft.com/en-us/library/system.printing.printcapabilities.pageborderlesscapability(v=vs.110).aspx
Most laser and inkjet printers do not support borderless printing. They must allow an unprinted margin to prevent toner from getting on the parts of the printer that move the paper. Many photographic printers, however, do support borderless printing. If the printer does not support borderless printing, the collection is empty.
Upvotes: 1