PrintingServicesWin32.cs 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583
  1. //
  2. // Copyright (C) 2005 Novell, Inc. http://www.novell.com
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining
  5. // a copy of this software and associated documentation files (the
  6. // "Software"), to deal in the Software without restriction, including
  7. // without limitation the rights to use, copy, modify, merge, publish,
  8. // distribute, sublicense, and/or sell copies of the Software, and to
  9. // permit persons to whom the Software is furnished to do so, subject to
  10. // the following conditions:
  11. //
  12. // The above copyright notice and this permission notice shall be
  13. // included in all copies or substantial portions of the Software.
  14. //
  15. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  16. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  17. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  18. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  19. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  20. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  21. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  22. //
  23. // Author:
  24. //
  25. // Jordi Mas i Hernandez, [email protected]
  26. //
  27. using System.Runtime.InteropServices;
  28. using System.Collections;
  29. using System.Drawing.Printing;
  30. using System.ComponentModel;
  31. using System.Text;
  32. namespace System.Drawing.Printing
  33. {
  34. internal class PrintingServicesWin32 : PrintingServices
  35. {
  36. internal PrintingServicesWin32 ()
  37. {
  38. }
  39. internal override void LoadPrinterSettings (string printer, PrinterSettings settings)
  40. {
  41. int ret;
  42. DEVMODE devmode;
  43. IntPtr hPrn = IntPtr.Zero;
  44. IntPtr ptr_dev = IntPtr.Zero;
  45. settings.maximum_copies = Win32DeviceCapabilities (printer, null, DCCapabilities.DC_COPIES, IntPtr.Zero, IntPtr.Zero);
  46. ret = Win32DeviceCapabilities (printer, null, DCCapabilities.DC_DUPLEX, IntPtr.Zero, IntPtr.Zero);
  47. settings.can_duplex = (ret == 1) ? true : false;
  48. ret = Win32DeviceCapabilities (printer, null, DCCapabilities.DC_COLORDEVICE, IntPtr.Zero, IntPtr.Zero);
  49. settings.supports_color = (ret == 1) ? true : false;
  50. ret = Win32DeviceCapabilities (printer, null, DCCapabilities.DC_ORIENTATION, IntPtr.Zero, IntPtr.Zero);
  51. if (ret != -1)
  52. settings.landscape_angle = ret;
  53. try {
  54. Win32OpenPrinter (printer, out hPrn, IntPtr.Zero);
  55. ret = Win32DocumentProperties (IntPtr.Zero, hPrn, null, IntPtr.Zero, IntPtr.Zero, 2);
  56. if (ret < 0)
  57. return;
  58. ptr_dev = Marshal.AllocHGlobal (ret);
  59. ret = Win32DocumentProperties (IntPtr.Zero, hPrn, null, ptr_dev, IntPtr.Zero, 2);
  60. devmode = (DEVMODE) Marshal.PtrToStructure (ptr_dev, typeof(DEVMODE));
  61. foreach (PaperSize paper_size in settings.PaperSizes) {
  62. if ((int) paper_size.Kind == devmode.dmPaperSize) {
  63. settings.DefaultPageSettings.PaperSize = paper_size;
  64. break;
  65. }
  66. }
  67. foreach (PaperSource paper_source in settings.PaperSources) {
  68. if ((int) paper_source.Kind == devmode.dmDefaultSource) {
  69. settings.DefaultPageSettings.PaperSource = paper_source;
  70. break;
  71. }
  72. }
  73. }
  74. finally {
  75. Win32ClosePrinter (hPrn);
  76. if (ptr_dev != IntPtr.Zero)
  77. Marshal.FreeHGlobal (ptr_dev);
  78. }
  79. }
  80. internal override void LoadPrinterResolutions (string printer, PrinterSettings settings)
  81. {
  82. int ret;
  83. IntPtr ptr, buff = IntPtr.Zero;
  84. settings.PrinterResolutions.Clear ();
  85. LoadDefaultResolutions (settings.PrinterResolutions);
  86. ret = Win32DeviceCapabilities (printer, null, DCCapabilities.DC_ENUMRESOLUTIONS, IntPtr.Zero, IntPtr.Zero);
  87. if (ret == -1)
  88. return;
  89. ptr = buff = Marshal.AllocHGlobal (ret * 2 * Marshal.SizeOf (buff));
  90. ret = Win32DeviceCapabilities (printer, null, DCCapabilities.DC_ENUMRESOLUTIONS, buff, IntPtr.Zero);
  91. int x, y;
  92. if (ret != -1) {
  93. for (int i = 0; i < ret; i++) {
  94. x = Marshal.ReadInt32 (ptr);
  95. ptr = new IntPtr (ptr.ToInt64 () + Marshal.SizeOf (x));
  96. y = Marshal.ReadInt32 (ptr);
  97. ptr = new IntPtr (ptr.ToInt64 () + Marshal.SizeOf (y));
  98. settings.PrinterResolutions.Add (new PrinterResolution
  99. (x,y, PrinterResolutionKind.Custom));
  100. }
  101. }
  102. Marshal.FreeHGlobal (buff);
  103. }
  104. internal override void LoadPrinterPaperSizes (string printer, PrinterSettings settings)
  105. {
  106. int items, ret;
  107. IntPtr ptr_names, buff_names = IntPtr.Zero;
  108. IntPtr ptr_sizes, buff_sizes = IntPtr.Zero;
  109. IntPtr ptr_sizes_enum, buff_sizes_enum = IntPtr.Zero;
  110. string name;
  111. settings.PaperSizes.Clear ();
  112. items = Win32DeviceCapabilities (printer, null, DCCapabilities.DC_PAPERSIZE, IntPtr.Zero, IntPtr.Zero);
  113. if (items == -1)
  114. return;
  115. try {
  116. ptr_sizes = buff_sizes = Marshal.AllocHGlobal (items * 2 * 4);
  117. ptr_names = buff_names = Marshal.AllocHGlobal (items * 64 * 2);
  118. ptr_sizes_enum = buff_sizes_enum = Marshal.AllocHGlobal (items * 2);
  119. ret = Win32DeviceCapabilities (printer, null, DCCapabilities.DC_PAPERSIZE, buff_sizes, IntPtr.Zero);
  120. if (ret == -1) {
  121. // the finally clause will free the unmanaged memory before returning
  122. return;
  123. }
  124. ret = Win32DeviceCapabilities (printer, null, DCCapabilities.DC_PAPERS, buff_sizes_enum, IntPtr.Zero);
  125. ret = Win32DeviceCapabilities (printer, null, DCCapabilities.DC_PAPERNAMES, buff_names, IntPtr.Zero);
  126. int x, y;
  127. PaperSize ps;
  128. PaperKind kind;
  129. for (int i = 0; i < ret; i++) {
  130. x = Marshal.ReadInt32 (ptr_sizes, i * 4);
  131. y = Marshal.ReadInt32 (ptr_sizes, (i + 1) * 4);
  132. x = PrinterUnitConvert.Convert (x, PrinterUnit.TenthsOfAMillimeter,
  133. PrinterUnit.Display);
  134. y = PrinterUnitConvert.Convert (y, PrinterUnit.TenthsOfAMillimeter,
  135. PrinterUnit.Display);
  136. name = Marshal.PtrToStringUni (ptr_names);
  137. ptr_names = new IntPtr (ptr_names.ToInt64 () + 64 * 2);
  138. kind = (PaperKind) Marshal.ReadInt16 (ptr_sizes_enum);
  139. ptr_sizes_enum = new IntPtr (ptr_sizes_enum.ToInt64 () + 2);
  140. ps = new PaperSize (name, x,y);
  141. ps.SetKind (kind);
  142. settings.PaperSizes.Add (ps);
  143. }
  144. }
  145. finally {
  146. if (buff_names != IntPtr.Zero)
  147. Marshal.FreeHGlobal (buff_names);
  148. if (buff_sizes != IntPtr.Zero)
  149. Marshal.FreeHGlobal (buff_sizes);
  150. if (buff_sizes_enum != IntPtr.Zero)
  151. Marshal.FreeHGlobal (buff_sizes_enum);
  152. }
  153. }
  154. internal override bool StartDoc (GraphicsPrinter gr, string doc_name, string output_file)
  155. {
  156. DOCINFO di = new DOCINFO ();
  157. int ret;
  158. di.cbSize = Marshal.SizeOf (di);
  159. di.lpszDocName = Marshal.StringToHGlobalUni (doc_name);
  160. di.lpszOutput = IntPtr.Zero;
  161. di.lpszDatatype = IntPtr.Zero;
  162. di.fwType = 0;
  163. ret = Win32StartDoc (gr.Hdc, ref di);
  164. Marshal.FreeHGlobal (di.lpszDocName);
  165. return (ret > 0) ? true : false;
  166. }
  167. internal override void LoadPrinterPaperSources (string printer, PrinterSettings settings)
  168. {
  169. int items, ret;
  170. IntPtr ptr_names, buff_names = IntPtr.Zero;
  171. IntPtr ptr_bins, buff_bins = IntPtr.Zero;
  172. PaperSourceKind kind;
  173. string name;
  174. settings.PaperSources.Clear ();
  175. items = Win32DeviceCapabilities (printer, null, DCCapabilities.DC_BINNAMES, IntPtr.Zero, IntPtr.Zero);
  176. if (items == -1)
  177. return;
  178. try {
  179. ptr_names = buff_names = Marshal.AllocHGlobal (items * 2 * 24);
  180. ptr_bins = buff_bins = Marshal.AllocHGlobal (items * 2);
  181. ret = Win32DeviceCapabilities (printer, null, DCCapabilities.DC_BINNAMES, buff_names, IntPtr.Zero);
  182. if (ret == -1) {
  183. // the finally clause will free the unmanaged memory before returning
  184. return;
  185. }
  186. ret = Win32DeviceCapabilities (printer, null, DCCapabilities.DC_BINS, buff_bins, IntPtr.Zero);
  187. for (int i = 0; i < ret; i++) {
  188. name = Marshal.PtrToStringUni (ptr_names);
  189. kind = (PaperSourceKind) Marshal.ReadInt16 (ptr_bins);
  190. settings.PaperSources.Add (new PaperSource (name, kind));
  191. ptr_names = new IntPtr (ptr_names.ToInt64 () + 24 * 2);
  192. ptr_bins = new IntPtr (ptr_bins.ToInt64 () + 2);
  193. }
  194. }
  195. finally {
  196. if (buff_names != IntPtr.Zero)
  197. Marshal.FreeHGlobal (buff_names);
  198. if (buff_bins != IntPtr.Zero)
  199. Marshal.FreeHGlobal (buff_bins);
  200. }
  201. }
  202. internal override bool StartPage (GraphicsPrinter gr)
  203. {
  204. int ret = Win32StartPage (gr.Hdc);
  205. return (ret > 0) ? true : false;
  206. }
  207. internal override bool EndPage (GraphicsPrinter gr)
  208. {
  209. int ret = Win32EndPage (gr.Hdc);
  210. return (ret > 0) ? true : false;
  211. }
  212. internal override bool EndDoc (GraphicsPrinter gr)
  213. {
  214. int ret = Win32EndDoc (gr.Hdc);
  215. Win32DeleteDC (gr.Hdc);
  216. gr.Graphics.Dispose ();
  217. return (ret > 0) ? true : false;
  218. }
  219. internal override IntPtr CreateGraphicsContext (PrinterSettings settings)
  220. {
  221. IntPtr dc = IntPtr.Zero;
  222. dc = Win32CreateDC (null, settings.PrinterName, null, IntPtr.Zero /* DEVMODE */);
  223. return dc;
  224. }
  225. // Properties
  226. internal override string DefaultPrinter {
  227. get {
  228. StringBuilder name = new StringBuilder (1024);
  229. int length = name.Capacity;
  230. Win32GetDefaultPrinter (name, ref length);
  231. return name.ToString ();
  232. }
  233. }
  234. internal override PrinterSettings.StringCollection InstalledPrinters {
  235. get {
  236. PrinterSettings.StringCollection col = new PrinterSettings.StringCollection (new string[] {});
  237. PRINTER_INFO printer_info;
  238. uint cbNeeded = 0, printers = 0;
  239. IntPtr ptr, buff;
  240. string s;
  241. // Determine space need it
  242. Win32EnumPrinters (2 /* PRINTER_ENUM_LOCAL */,
  243. null, 2, IntPtr.Zero, 0, ref cbNeeded, ref printers);
  244. ptr = buff = Marshal.AllocHGlobal ((int) cbNeeded);
  245. try {
  246. // Give us the printer list
  247. Win32EnumPrinters (2 /* PRINTER_ENUM_LOCAL */,
  248. null, 2, buff, (uint)cbNeeded, ref cbNeeded, ref printers);
  249. for (int i = 0; i < printers; i++) {
  250. printer_info = (PRINTER_INFO) Marshal.PtrToStructure (ptr, typeof (PRINTER_INFO));
  251. s = Marshal.PtrToStringUni (printer_info.pPrinterName);
  252. col.Add (s);
  253. ptr = new IntPtr (ptr.ToInt64 () + Marshal.SizeOf (printer_info));
  254. }
  255. }
  256. finally {
  257. Marshal.FreeHGlobal (buff);
  258. }
  259. return col;
  260. }
  261. }
  262. internal override void GetPrintDialogInfo (string printer, ref string port, ref string type, ref string status, ref string comment)
  263. {
  264. IntPtr hPrn;
  265. PRINTER_INFO printer_info = new PRINTER_INFO ();
  266. int needed = 0;
  267. IntPtr ptr;
  268. Win32OpenPrinter (printer, out hPrn, IntPtr.Zero);
  269. if (hPrn == IntPtr.Zero)
  270. return;
  271. Win32GetPrinter (hPrn, 2, IntPtr.Zero, 0, ref needed);
  272. ptr = Marshal.AllocHGlobal (needed);
  273. Win32GetPrinter (hPrn, 2, ptr, needed, ref needed);
  274. printer_info = (PRINTER_INFO) Marshal.PtrToStructure (ptr, typeof (PRINTER_INFO));
  275. Marshal.FreeHGlobal (ptr);
  276. port = Marshal.PtrToStringUni (printer_info.pPortName);
  277. comment = Marshal.PtrToStringUni (printer_info.pComment);
  278. type = Marshal.PtrToStringUni (printer_info.pDriverName);
  279. status = GetPrinterStatusMsg (printer_info.Status);
  280. Win32ClosePrinter (hPrn);
  281. }
  282. private string GetPrinterStatusMsg (uint status)
  283. {
  284. string rslt = string.Empty;
  285. if (status == 0)
  286. return "Ready";
  287. if ((status & (uint) PrinterStatus.PS_PAUSED) != 0) rslt += "Paused; ";
  288. if ((status & (uint) PrinterStatus.PS_ERROR) != 0) rslt += "Error; ";
  289. if ((status & (uint) PrinterStatus.PS_PENDING_DELETION) != 0) rslt += "Pending deletion; ";
  290. if ((status & (uint) PrinterStatus.PS_PAPER_JAM) != 0) rslt += "Paper jam; ";
  291. if ((status & (uint) PrinterStatus.PS_PAPER_OUT) != 0) rslt += "Paper out; ";
  292. if ((status & (uint) PrinterStatus.PS_MANUAL_FEED) != 0) rslt += "Manual feed; ";
  293. if ((status & (uint) PrinterStatus.PS_PAPER_PROBLEM) != 0) rslt += "Paper problem; ";
  294. if ((status & (uint) PrinterStatus.PS_OFFLINE) != 0) rslt += "Offline; ";
  295. if ((status & (uint) PrinterStatus.PS_IO_ACTIVE) != 0) rslt += "I/O active; ";
  296. if ((status & (uint) PrinterStatus.PS_BUSY) != 0) rslt += "Busy; ";
  297. if ((status & (uint) PrinterStatus.PS_PRINTING) != 0) rslt += "Printing; ";
  298. if ((status & (uint) PrinterStatus.PS_OUTPUT_BIN_FULL) != 0) rslt += "Output bin full; ";
  299. if ((status & (uint) PrinterStatus.PS_NOT_AVAILABLE) != 0) rslt += "Not available; ";
  300. if ((status & (uint) PrinterStatus.PS_WAITING) != 0) rslt += "Waiting; ";
  301. if ((status & (uint) PrinterStatus.PS_PROCESSING) != 0) rslt += "Processing; ";
  302. if ((status & (uint) PrinterStatus.PS_INITIALIZING) != 0) rslt += "Initializing; ";
  303. if ((status & (uint) PrinterStatus.PS_WARMING_UP) != 0) rslt += "Warming up; ";
  304. if ((status & (uint) PrinterStatus.PS_TONER_LOW) != 0) rslt += "Toner low; ";
  305. if ((status & (uint) PrinterStatus.PS_NO_TONER) != 0) rslt += "No toner; ";
  306. if ((status & (uint) PrinterStatus.PS_PAGE_PUNT) != 0) rslt += "Page punt; ";
  307. if ((status & (uint) PrinterStatus.PS_USER_INTERVENTION) != 0) rslt += "User intervention; ";
  308. if ((status & (uint) PrinterStatus.PS_OUT_OF_MEMORY) != 0) rslt += "Out of memory; ";
  309. if ((status & (uint) PrinterStatus.PS_DOOR_OPEN) != 0) rslt += "Door open; ";
  310. if ((status & (uint) PrinterStatus.PS_SERVER_UNKNOWN) != 0) rslt += "Server unkown; ";
  311. if ((status & (uint) PrinterStatus.PS_POWER_SAVE) != 0) rslt += "Power save; ";
  312. return rslt;
  313. }
  314. //
  315. // DllImports
  316. //
  317. [DllImport("winspool.drv", CharSet=CharSet.Unicode, EntryPoint="OpenPrinter", SetLastError=true)]
  318. static extern int Win32OpenPrinter (string pPrinterName, out IntPtr phPrinter, IntPtr pDefault);
  319. [DllImport("winspool.drv", CharSet=CharSet.Unicode, EntryPoint="GetPrinter", SetLastError=true)]
  320. static extern int Win32GetPrinter (IntPtr hPrinter, int level, IntPtr dwBuf, int size, ref int dwNeeded);
  321. [DllImport("winspool.drv", CharSet=CharSet.Unicode, EntryPoint="ClosePrinter", SetLastError=true)]
  322. static extern int Win32ClosePrinter (IntPtr hPrinter);
  323. [DllImport("winspool.drv", CharSet=CharSet.Unicode, EntryPoint="DeviceCapabilities", SetLastError=true)]
  324. static extern int Win32DeviceCapabilities (string device, string port, DCCapabilities cap, IntPtr outputBuffer, IntPtr deviceMode);
  325. [DllImport("winspool.drv", CharSet=CharSet.Unicode, EntryPoint="EnumPrinters", SetLastError=true)]
  326. static extern int Win32EnumPrinters (int Flags, string Name, uint Level, IntPtr pPrinterEnum, uint cbBuf,
  327. ref uint pcbNeeded, ref uint pcReturned);
  328. [DllImport("winspool.drv", EntryPoint="GetDefaultPrinter", CharSet=CharSet.Unicode, SetLastError=true)]
  329. private static extern int Win32GetDefaultPrinter (StringBuilder buffer, ref int bufferSize);
  330. [DllImport("winspool.drv", EntryPoint="DocumentProperties", CharSet=CharSet.Unicode, SetLastError=true)]
  331. private static extern int Win32DocumentProperties (IntPtr hwnd, IntPtr hPrinter, string pDeviceName,
  332. IntPtr pDevModeOutput, IntPtr pDevModeInput, int fMode);
  333. [DllImport("gdi32.dll", EntryPoint="CreateDC")]
  334. static extern IntPtr Win32CreateDC (string lpszDriver, string lpszDevice,
  335. string lpszOutput, IntPtr lpInitData);
  336. [DllImport("gdi32.dll", CharSet=CharSet.Unicode, EntryPoint="StartDoc")]
  337. static extern int Win32StartDoc (IntPtr hdc, [In] ref DOCINFO lpdi);
  338. [DllImport("gdi32.dll", EntryPoint="StartPage")]
  339. static extern int Win32StartPage (IntPtr hDC);
  340. [DllImport("gdi32.dll", EntryPoint="EndPage")]
  341. static extern int Win32EndPage (IntPtr hdc);
  342. [DllImport("gdi32.dll", EntryPoint="EndDoc")]
  343. static extern int Win32EndDoc (IntPtr hdc);
  344. [DllImport("gdi32.dll", EntryPoint="DeleteDC")]
  345. public static extern IntPtr Win32DeleteDC (IntPtr hDc);
  346. //
  347. // Structs
  348. //
  349. [StructLayout (LayoutKind.Sequential)]
  350. internal struct PRINTER_INFO
  351. {
  352. public IntPtr pServerName;
  353. public IntPtr pPrinterName;
  354. public IntPtr pShareName;
  355. public IntPtr pPortName;
  356. public IntPtr pDriverName;
  357. public IntPtr pComment;
  358. public IntPtr pLocation;
  359. public IntPtr pDevMode;
  360. public IntPtr pSepFile;
  361. public IntPtr pPrintProcessor;
  362. public IntPtr pDatatype;
  363. public IntPtr pParameters;
  364. public IntPtr pSecurityDescriptor;
  365. public uint Attributes;
  366. public uint Priority;
  367. public uint DefaultPriority;
  368. public uint StartTime;
  369. public uint UntilTime;
  370. public uint Status;
  371. public uint cJobs;
  372. public uint AveragePPM;
  373. }
  374. [StructLayout (LayoutKind.Sequential)]
  375. internal struct DOCINFO
  376. {
  377. public int cbSize;
  378. public IntPtr lpszDocName;
  379. public IntPtr lpszOutput;
  380. public IntPtr lpszDatatype;
  381. public int fwType;
  382. }
  383. [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Unicode)]
  384. internal struct DEVMODE
  385. {
  386. [MarshalAs(UnmanagedType.ByValTStr,SizeConst=32)]
  387. public string dmDeviceName;
  388. public short dmSpecVersion;
  389. public short dmDriverVersion;
  390. public short dmSize;
  391. public short dmDriverExtra;
  392. public int dmFields;
  393. public short dmOrientation;
  394. public short dmPaperSize;
  395. public short dmPaperLength;
  396. public short dmPaperWidth;
  397. public short dmScale;
  398. public short dmCopies;
  399. public short dmDefaultSource;
  400. public short dmPrintQuality;
  401. public short dmColor;
  402. public short dmDuplex;
  403. public short dmYResolution;
  404. public short dmTTOption;
  405. public short dmCollate;
  406. [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)]
  407. public string dmFormName;
  408. public short dmLogPixels;
  409. public short dmBitsPerPel;
  410. public int dmPelsWidth;
  411. public int dmPelsHeight;
  412. public int dmDisplayFlags;
  413. public int dmDisplayFrequency;
  414. public int dmICMMethod;
  415. public int dmICMIntent;
  416. public int dmMediaType;
  417. public int dmDitherType;
  418. public int dmReserved1;
  419. public int dmReserved2;
  420. public int dmPanningWidth;
  421. public int dmPanningHeight;
  422. }
  423. // Enums
  424. internal enum DCCapabilities : short
  425. {
  426. DC_FIELDS = 1,
  427. DC_PAPERS = 2,
  428. DC_PAPERSIZE = 3,
  429. DC_MINEXTENT = 4,
  430. DC_MAXEXTENT = 5,
  431. DC_BINS = 6,
  432. DC_DUPLEX = 7,
  433. DC_SIZE = 8,
  434. DC_EXTRA = 9,
  435. DC_VERSION = 10,
  436. DC_DRIVER = 11,
  437. DC_BINNAMES = 12,
  438. DC_ENUMRESOLUTIONS = 13,
  439. DC_FILEDEPENDENCIES = 14,
  440. DC_TRUETYPE = 15,
  441. DC_PAPERNAMES = 16,
  442. DC_ORIENTATION = 17,
  443. DC_COPIES = 18,
  444. DC_BINADJUST = 19,
  445. DC_EMF_COMPLIANT = 20,
  446. DC_DATATYPE_PRODUCED = 21,
  447. DC_COLLATE = 22,
  448. DC_MANUFACTURER = 23,
  449. DC_MODEL = 24,
  450. DC_PERSONALITY = 25,
  451. DC_PRINTRATE = 26,
  452. DC_PRINTRATEUNIT = 27,
  453. DC_PRINTERMEM = 28,
  454. DC_MEDIAREADY = 29,
  455. DC_STAPLE = 30,
  456. DC_PRINTRATEPPM = 31,
  457. DC_COLORDEVICE = 32,
  458. DC_NUP = 33
  459. }
  460. [Flags]
  461. internal enum PrinterStatus : uint
  462. {
  463. PS_PAUSED = 0x00000001,
  464. PS_ERROR = 0x00000002,
  465. PS_PENDING_DELETION = 0x00000004,
  466. PS_PAPER_JAM = 0x00000008,
  467. PS_PAPER_OUT = 0x00000010,
  468. PS_MANUAL_FEED = 0x00000020,
  469. PS_PAPER_PROBLEM = 0x00000040,
  470. PS_OFFLINE = 0x00000080,
  471. PS_IO_ACTIVE = 0x00000100,
  472. PS_BUSY = 0x00000200,
  473. PS_PRINTING = 0x00000400,
  474. PS_OUTPUT_BIN_FULL = 0x00000800,
  475. PS_NOT_AVAILABLE = 0x00001000,
  476. PS_WAITING = 0x00002000,
  477. PS_PROCESSING = 0x00004000,
  478. PS_INITIALIZING = 0x00008000,
  479. PS_WARMING_UP = 0x00010000,
  480. PS_TONER_LOW = 0x00020000,
  481. PS_NO_TONER = 0x00040000,
  482. PS_PAGE_PUNT = 0x00080000,
  483. PS_USER_INTERVENTION = 0x00100000,
  484. PS_OUT_OF_MEMORY = 0x00200000,
  485. PS_DOOR_OPEN = 0x00400000,
  486. PS_SERVER_UNKNOWN = 0x00800000,
  487. PS_POWER_SAVE = 0x01000000
  488. }
  489. }
  490. }