/// <summary> /// Prints bytes to the printer. /// </summary> /// <param name="name">Print job name</param> /// <param name="dataType">Type of printing</param> /// <param name="bytes">bytes to print</param> public PrintJob(string name, DataType dataType, byte[] bytes) { DocInfo1 = new DOC_INFO_1() { pDocName = name, pDataType = dataType.ToString() }; Bytes = bytes; }
/// <summary> /// Notifies the print spooler that a document is to be spooled for printing. /// </summary> /// <param name="di1"></param> /// <returns></returns> protected uint StartDocPrinter(DOC_INFO_1 di1) { var id = NativeMethods.StartDocPrinterW(_printerHandle, 1, ref di1); if (id == 0) { if (Marshal.GetLastWin32Error() == 1804) { throw new Exception("The specified datatype is invalid, try setting " + "'Enable advanced printing features' in printer properties.", new Win32Exception()); } throw new Win32Exception(); } return(id); }
public static extern uint StartDocPrinterW(IntPtr hPrinter, uint level, [In] ref DOC_INFO_1 di1);