printer
Retrieving Printer Capabilities
In Enumerating printer forms article the DeviceCapabilities function is used to mark print forms supported by particular printer. It can be used to retrieve other printer capabilities as well.
Add and delete custom printer forms
To distribute applications that use reports with custom paper size you have to create custom printer forms on every destination PC that runs Windows 2000 or later. The MS KB article Q157172 explains how it can be done manually. However there's a way to do that programmatically using Windows API.
Enumerating printer forms
Enumerating of printer forms can be done with Windows API EnumForms function. Contrary to what MSDN says, it returns the list of all printer forms on PC, not just for the specific printer. On other hand, DeviceCapabilities can return a list of supported paper sizes for the printer.
Get number of jobs in print queue
The number of jobs in print queue can be retrieved by simplified version of Enumerating jobs in print queue
Enumerating jobs in print queue
Enumerating jobs in a print queue can be done with
- WMI Win32_PrintJob class
- Windows API EnumJobs function.
How to delete all Print Jobs from a print queue
All jobs from a print queue can be deleted with
- WMI Win32_Printer class and CancelAllJobs method
- Windows API SetPrinter function.
Determine Printer Margins Programmatically
The GetDeviceCaps function can be used to retrieve printer-specific information as demonstrated below.
| This is sample code. Add error handling and adjust to your requirements as necessary. |
CLEAR #DEFINE LOGPIXELSX 88 && Logical pixels/inch in X #DEFINE LOGPIXELSY 90 && Logical pixels/inch in Y #DEFINE PHYSICALWIDTH 110 && Physical Width in device units #DEFINE PHYSICALHEIGHT 111 && Physical Height in device units #DEFINE PHYSICALOFFSETX 112 && Physical Printable Area x margin
Recent comments
9 hours 35 min ago
3 days 12 hours ago
2 weeks 9 hours ago
2 weeks 13 hours ago
3 weeks 3 days ago
4 weeks 2 days ago
4 weeks 2 days ago
4 weeks 2 days ago
4 weeks 2 days ago
5 weeks 2 hours ago