![]() ![]() This is only for printing operation on one webview. If Print is called while a PrintAsync(CoreWebView2PrintSettings) or PrintToPdfAsync(String, CoreWebView2PrintSettings) or PrintToPdfStreamAsync(CoreWebView2PrintSettings) job is in progress, Task throws exception. Only one Printing operation can be in progress at a time. The async Print operation completes when it finishes printing to the printer. The method will throw ArgumentException if the caller provides invalid settings for a given printer. The method will return CoreWebView2PrintStatus as PrinterUnavailable if printerName doesn't match with the name of any installed printers on the user OS. Passing null for printSettings results in default print settings used. See CoreWebView2PrintSettings for description of settings. MessageBox.Show(this, "Printing " + title + " document already in progress", MessageBox.Show(this, "Invalid settings provided for the specified printer", MessageBox.Show(this, "Printing " + title + " document to printer is failed", MessageBox.Show(this, "Selected printer is not found, not available, offline or error state", "Print to printer") MessageBox.Show(this, "Printing " + title + " document to printer is succeeded", "Print to printer") Įlse if (printStatus = CoreWebView2PrintStatus.PrinterUnavailable) If (printStatus = CoreWebView2PrintStatus.Succeeded) String title = ĬoreWebView2PrintStatus printStatus = await (printSettings) This example prints the current web page to the specified printer with the settings.ĬoreWebView2PrintSettings printSettings = GetSelectedPrinterPrintSettings(printerName) Display the printer capabilities to the user along with the page settings. to get the capabilities of the selected printer. Get PrintQueue for the selected printer and use GetPrintCapabilities() of PrintQueue from System.Printing PrintSettings.ShouldPrintHeaderAndFooter = true PrintSettings.ShouldPrintBackgrounds = true PrintSettings = WebViewEnvironment.CreatePrintSettings() the print settings for the current web page and for the selected printer.ĬoreWebView2PrintSettings GetSelectedPrinterPrintSettings(string printerName)ĬoreWebView2PrintSettings printSettings = null You may also choose get the capabilties from the native printer API, display to the user to get Function to get print settings for the selected printer. Return the user selected printer name. Display the printer list to the user and get the desired printer to print. Use GetPrintQueues() of LocalPrintServer from System.Printing to get list of locally installed printers. You may also choose to display printers list to the user and return user selected printer.ĭescription: "Specify a printer name from the installed printers list on the OS.", User has to specify the desired printer name by querying the installed printers list on the PrintSettings CoreWebView2PrintSettings Returns TaskĮxamples // Function to get printer name by displaying printer text input dialog to the user. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |