private void BtnPrint_Click(object sender, EventArgs e) { btnPrint.Enabled = false; currentPageIndex = 0; var backgroundScheduler = TaskScheduler.Default; var uiScheduler = TaskScheduler.FromCurrentSynchronizationContext(); CancellationTokenSource cts = new CancellationTokenSource(); CancellationToken token = cts.Token; Task.Factory.StartNew(delegate { System.Drawing.Printing.PrintController printController = new System.Drawing.Printing.StandardPrintController(); // 不显示系统默认的打印进度 pdfDocumentViewer1.PrintSettings.PrintController = printController; pdfDocumentViewer1.PrintSettings.PrintPage += PrintSettings_PrintPage; pdfDocumentViewer1.PrintSettings.BeginPrint += PrintSettings_BeginPrint; pdfDocumentViewer1.PrintSettings.EndPrint += PrintSettings_EndPrint; pdfDocumentViewer1.PrintDoc(); }, token, TaskCreationOptions.None, backgroundScheduler). ContinueWith(delegate { btnPrint.Enabled = true; }, token, TaskContinuationOptions.None, uiScheduler); }
public static void Print_Queue(BOL.Transaction_Queue.objTransactionQueue trans_queue) { BackgroundWorker bw = new BackgroundWorker(); bw.DoWork += (s, arg) => { try { rptQueueTicket report = new rptQueueTicket(trans_queue) { Name = "Queue Ticket" }; ReportSource report_source = new InstanceReportSource() { ReportDocument = report }; // Obtain the settings of the default printer System.Drawing.Printing.PrinterSettings printerSettings = new System.Drawing.Printing.PrinterSettings(); // The standard print controller comes with no UI System.Drawing.Printing.PrintController standardPrintController = new System.Drawing.Printing.StandardPrintController(); // Print the report using the custom print controller Telerik.Reporting.Processing.ReportProcessor reportProcessor = new Telerik.Reporting.Processing.ReportProcessor(); reportProcessor.PrintController = standardPrintController; //reportProcessor.PrintReport(typeReportSource, printerSettings); reportProcessor.PrintReport(report_source, printerSettings); } catch (Exception ex) { EventLog.WriteEntry("Report", ex.Message, EventLogEntryType.Error); } }; //bw.RunWorkerCompleted += (s, arg) => //{ // if (arg.Error == null) // { // } // else // throw new Exception(arg.Error.Message); //}; bw.RunWorkerAsync(); }
public void Window_Loaded(object sender, RoutedEventArgs e) { this.Hide(); RptPagare report = new RptPagare(UsarFolio, UsarCantidad, UsarFecha, UsarCantLetra, UsarNumPagare, UsarNumPagares, UsarNombre, UsarDireccion, UsarColonia, UsarCiudad, UsarEstado); ReportViewer.Report = report; ReportViewer.RefreshReport(); //-------Que muestra previsualizador de que se esta imprimiendo //System.Drawing.Printing.PrinterSettings printerSettings // = new System.Drawing.Printing.PrinterSettings(); //Telerik.Reporting.Processing.ReportProcessor reportProcessor // = new Telerik.Reporting.Processing.ReportProcessor(); //Telerik.Reporting.TypeReportSource typeReportSource = // new Telerik.Reporting.TypeReportSource(); //reportProcessor.PrintReport(report, printerSettings); // ------------codigo // Obtain the settings of the default printer System.Drawing.Printing.PrinterSettings printerSettings = new System.Drawing.Printing.PrinterSettings(); //--------- The standard print controller comes with no UI----------// System.Drawing.Printing.PrintController standardPrintController = new System.Drawing.Printing.StandardPrintController(); // Print the report using the custom print controller Telerik.Reporting.Processing.ReportProcessor reportProcessor = new Telerik.Reporting.Processing.ReportProcessor(); reportProcessor.PrintController = standardPrintController; Telerik.Reporting.TypeReportSource typeReportSource = new Telerik.Reporting.TypeReportSource(); reportProcessor.PrintReport(report, printerSettings); }
public static void Run() { // ExStart:PrintProgressDialog // The path to the documents directory. string dataDir = RunExamples.GetDataDir_RenderingAndPrinting(); // Load the documents which store the shapes we want to render. Document doc = new Document(dataDir + "TestFile RenderShape.doc"); // Obtain the settings of the default printer System.Drawing.Printing.PrinterSettings settings = new System.Drawing.Printing.PrinterSettings(); // The standard print controller comes with no UI System.Drawing.Printing.PrintController standardPrintController = new System.Drawing.Printing.StandardPrintController(); // Print the document using the custom print controller AsposeWordsPrintDocument prntDoc = new AsposeWordsPrintDocument(doc); prntDoc.PrinterSettings = settings; prntDoc.PrintController = standardPrintController; prntDoc.Print(); // ExEnd:PrintProgressDialog }
public static void Run() { // ExStart:PrintProgressDialog // The path to the documents directory. string dataDir = RunExamples.GetDataDir_RenderingAndPrinting(); // Load the documents which store the shapes we want to render. Document doc = new Document(dataDir + "TestFile RenderShape.doc"); // Obtain the settings of the default printer System.Drawing.Printing.PrinterSettings settings = new System.Drawing.Printing.PrinterSettings(); // The standard print controller comes with no UI System.Drawing.Printing.PrintController standardPrintController = new System.Drawing.Printing.StandardPrintController(); // Print the document using the custom print controller AsposeWordsPrintDocument prntDoc = new AsposeWordsPrintDocument(doc); prntDoc.PrinterSettings = settings; prntDoc.PrintController = standardPrintController; prntDoc.Print(); // ExEnd:PrintProgressDialog }
protected void ImageButton1_Click(object sender, ImageClickEventArgs e) { try { System.Drawing.Printing.PrinterSettings printerSettings = new System.Drawing.Printing.PrinterSettings(); // The standard print controller comes with no UI System.Drawing.Printing.PrintController standardPrintController = new System.Drawing.Printing.StandardPrintController(); // Print the report using the custom print controller Telerik.Reporting.Processing.ReportProcessor reportProcessor = new Telerik.Reporting.Processing.ReportProcessor(); //reportProcessor.PrintController = standardPrintController; //reportProcessor.PrintReport(ViewRptSumario.Report, printerSettings); Hashtable deviceInfo = new Hashtable(); deviceInfo.Add("ImmediatePrint", true); reportProcessor.RenderReport("PDF", ViewRptSumario.Report, deviceInfo); reportProcessor.PrintReport(ViewRptSumario.Report, printerSettings); //if (m_fDataAlta) //{ // //Atualiza Data Impressão // m_oSumario.DATA_IMPRESSAO_SUMARIO = Convert.ToDateTime(DateTime.Now); // m_oSumario.SalvarSumario_Impressao(Convert.ToInt32(UtSessao.Sessao["Id058"])); // UtSessao.Sessao["Habilita"] = "N"; // ExibirMensagemPopUp("Sumário de Alta foi Fechado com sucesso!!!"); //} //else //{ // ExibirMensagemPopUp("Data da Alta - não informada!!!"); //} } catch (Exception ex) { ExibirMensagemPopUp(ex.Message); } if (UtSessao.Sessao["Habilita"].ToString() == "S") { if (m_fDataAlta) { //Atualiza Data Impressão m_oSumario.DATA_IMPRESSAO_SUMARIO = Convert.ToDateTime(DateTime.Now); m_oSumario.SalvarSumario_Impressao(Convert.ToInt32(UtSessao.Sessao["Id058"])); UtSessao.Sessao["Habilita"] = "N"; ExibirMensagemPopUp("Sumário de Alta foi Fechado com sucesso!!!"); } else { ExibirMensagemPopUp("Data da Alta - não informada!!!"); } } }