private void DocPrinter(SafePrinter printer, string documentName, string dataType, Stream stream, bool paused, int pagecount, string printerName) { var di1 = new DOC_INFO_1 { pDataType = dataType, pDocName = documentName, }; var id = printer.StartDocPrinter(di1); if (paused) { NativeMethods.SetJob(printer.DangerousGetHandle(), id, 0, IntPtr.Zero, (int)JobControl.Pause); } OnJobCreated?.Invoke(this, new JobCreatedEventArgs { Id = id, PrinterName = printerName }); try { PagePrinter(printer, stream, pagecount); } finally { printer.EndDocPrinter(); } }
public uint StartDocPrinter(DOC_INFO_1 di1) { var id = NativeMethods.StartDocPrinterW(handle, 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, [MarshalAs(UnmanagedType.Struct)] ref DOC_INFO_1 di1);