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 void StartDocPrinter(DOC_INFO_1 di1) { if (NativeMethods.StartDocPrinterW(handle, 1, ref di1) == 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(); } }
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); }
private static void DocPrinter(SafePrinter printer, string documentName, string dataType, Stream stream) { var di1 = new DOC_INFO_1 { pDataType = dataType, pDocName = documentName, }; printer.StartDocPrinter(di1); try { PagePrinter(printer, stream); } finally { printer.EndDocPrinter(); } }
private static void DocPrinter(SafePrinter printer, string documentName, string dataType, Stream stream, bool paused) { 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); } try { PagePrinter(printer, stream); } finally { printer.EndDocPrinter(); } }
public static extern uint StartDocPrinterW(IntPtr hPrinter, uint level, [MarshalAs(UnmanagedType.Struct)] ref DOC_INFO_1 di1);