CoreWebView2.PrintToPdfAsync(String, CoreWebView2PrintSettings) Method

Definition

Print the current page to PDF asynchronously with the provided settings.

public System.Threading.Tasks.Task<bool> PrintToPdfAsync (string ResultFilePath, Microsoft.Web.WebView2.Core.CoreWebView2PrintSettings printSettings = default);
member this.PrintToPdfAsync : string * Microsoft.Web.WebView2.Core.CoreWebView2PrintSettings -> System.Threading.Tasks.Task<bool>
Public Function PrintToPdfAsync (ResultFilePath As String, Optional printSettings As CoreWebView2PrintSettings = Nothing) As Task(Of Boolean)

Parameters

ResultFilePath
String

Returns

Remarks

See CoreWebView2PrintSettings for description of settings. Passing null for printSettings results in default print settings used.

Use resultFilePath to specify the path to the PDF file. The host should provide an absolute path, including file name. If the path points to an existing file, the file will be overwritten. If the path is not valid, the method fails.

The async PrintToPdf operation completes when the data has been written to the PDF file. If the application exits before printing is complete, the file is not saved. Only one `Printing` operation can be in progress at a time. If PrintToPdf is called while a `PrintToPdf` or `PrintToPdfStream` or `Print` operation is in progress, the operation completes and returns false.

Applies to