private bool CheckFileForPrintWaiting(PrintEventArgs p) { var fileName = p.EventData.FileName; var fileId = AboutPagesOfDocument.ToString(p.EventData.JobDetail.JobInfo2.TotalPages, p.EventData.JobDetail.DevMode.dmCopies); var isExistsFileWaitingForPrint = FilesWaitsPrinting.Remove(fileId); if (!isExistsFileWaitingForPrint) { _logger.Debug("Такой файл не ожидает печати"); return(false); } return(true); }
private void OpenWordPrintDialog(Document d) { PrintDialog pDialog = new PrintDialog(); pDialog.PrinterSettings.Copies = 10; pDialog.PrinterSettings.FromPage = 1; pDialog.PrinterSettings.ToPage = 1; pDialog.Document = new PrintDocument(); // pDialog.Document.DocumentName = TicketRegistry.Get(); pDialog.PrinterSettings.PrintRange = PrintRange.AllPages; pDialog.AllowSomePages = true; pDialog.AllowSelection = true; if (pDialog.ShowDialog() == DialogResult.OK) { d.Application.ActivePrinter = pDialog.PrinterSettings.PrinterName; d.Activate(); object back = false; object append = true; object copies = pDialog.PrinterSettings.Copies.ToString(); object from = pDialog.PrinterSettings.FromPage.ToString(); object to = pDialog.PrinterSettings.ToPage.ToString(); object pages = ""; FilesWaitsPrinting.Add(d.FullName, new AboutPagesOfDocument("2", copies)); _logger.Debug($"Диалог печати - ОК. Количество копий {copies}, листы от {from}, до {to}"); d.Application.ActiveDocument.PrintOut( Background: ref back, Pages: ref pages, Range: WdPrintOutRange.wdPrintFromTo , Item: WdPrintOutItem.wdPrintDocumentContent , PageType: WdPrintOutPages.wdPrintAllPages , Append: ref append, Copies: ref copies , From: ref from , To: ref to); // pDialog.Document.Print(); //this will also work: doc.PrintOut(); d.Close(SaveChanges: false); //d = null; } }