A
Aleksey Malyshev
Guest
I have a legacy application that uses System.Drawing.Printing.PrintDocument(). It all works great, but the system leaves hard margins, which are .16". I need to add support for borderless printing.
I checked documentation and added some code to make sure that my printer supports PageBorderless.Borderless capability (see the code sample below), which will supposedly allow me to print edge to edge. But here is the problem - how can I use the former interface to print borderless? In PrinterSettings I can specify a lot of stuff, but not PageBorderless. As far as I could find, I need to get a PrintTicket to specify PageBorderless capability. I tried to use DefaultPrintTicket, like in the sample below, but it does not affect the printing job, I still get hard margins of .16".
var localPrintServer = new LocalPrintServer();
var localPrinterCollection = localPrintServer.GetPrintQueues();
var printQueue = localPrinterCollection.FirstOrDefault(pq => pq.FullName == _printer.Name);
if (printQueue == null)
{
return;
}
var printTicket = printQueue.DefaultPrintTicket;
var printCapabilities = printQueue.GetPrintCapabilities();
if (printCapabilities.PageBorderlessCapability.Contains(PageBorderless.Borderless))
{
printTicket.PageBorderless = PageBorderless.Borderless;
_logger.Trace("Set borderless print capability");
}
If I understand correctly from this page, System.Drawing.Printing.PrintDocument uses GDI interface, which is independent from Print Ticket API. Although I was not able to find a confirmation for this assumption, if it is correct, I will not be able to get a PrintTicket object from PrintDocument or pass it there. Is there any other way to specify Boderless capability?
<style type="text/css">p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.5px Helvetica; background-color: #000000} </style><style type="text/css">p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.5px Helvetica; background-color: #000000} </style>
<style type="text/css">p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.5px Helvetica; background-color: #000000} </style>
Continue reading...
I checked documentation and added some code to make sure that my printer supports PageBorderless.Borderless capability (see the code sample below), which will supposedly allow me to print edge to edge. But here is the problem - how can I use the former interface to print borderless? In PrinterSettings I can specify a lot of stuff, but not PageBorderless. As far as I could find, I need to get a PrintTicket to specify PageBorderless capability. I tried to use DefaultPrintTicket, like in the sample below, but it does not affect the printing job, I still get hard margins of .16".
var localPrintServer = new LocalPrintServer();
var localPrinterCollection = localPrintServer.GetPrintQueues();
var printQueue = localPrinterCollection.FirstOrDefault(pq => pq.FullName == _printer.Name);
if (printQueue == null)
{
return;
}
var printTicket = printQueue.DefaultPrintTicket;
var printCapabilities = printQueue.GetPrintCapabilities();
if (printCapabilities.PageBorderlessCapability.Contains(PageBorderless.Borderless))
{
printTicket.PageBorderless = PageBorderless.Borderless;
_logger.Trace("Set borderless print capability");
}
If I understand correctly from this page, System.Drawing.Printing.PrintDocument uses GDI interface, which is independent from Print Ticket API. Although I was not able to find a confirmation for this assumption, if it is correct, I will not be able to get a PrintTicket object from PrintDocument or pass it there. Is there any other way to specify Boderless capability?
<style type="text/css">p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.5px Helvetica; background-color: #000000} </style><style type="text/css">p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.5px Helvetica; background-color: #000000} </style>
<style type="text/css">p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.5px Helvetica; background-color: #000000} </style>
Continue reading...