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(); } }
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(); } }