Hello @Paliwal, Vishal (Cognizant) ,
From the codes you provided, I see that you want to print this PDFWKWebView
, saving PDF is disabled because the preview of this page is blank in the lower version. If the preview is loaded, you could long press or zoom on this preview, then you will go to the detail page, and you could save this PDF file by clicking the share button. To make sure the preview can load, try to call this PrintPDF()
method after all the data of webview is loaded (use WKNavigationDelegate.DidFinishNavigation(WKWebView, WKNavigation) Method ). Refer to the following code:
public void LoadWebView()//load a webview to test
{
WKWebView PDFWKWebView = new WKWebView(new CoreGraphics.CGRect(0, 0, 300, 300), new WKWebViewConfiguration());
PDFWKWebView.NavigationDelegate = new WKWebViewDelegate();//key point, set NavigationDelegate
var url = new NSUrl("https://learn.microsoft.com");
var request = new NSUrlRequest(url);
PDFWKWebView.LoadRequest(request);
}
The WKWebViewDelegate
class extending from WKNavigationDelegate
public class WKWebViewDelegate : WKNavigationDelegate
{
public override void DidFinishNavigation(WKWebView webView, WKNavigation navigation)
{
PrintPDF(webView);
}
public void PrintPDF(WKWebView PDFWKWebView)
{
......//your method
}
}
But the Print button will be disabled before selecting the printer.
--------UPDATE--------
After iOS 15, when you click print button, this Print Opentions
view will pop up. Before iOS15, you need to long press the preview or two fingers to zoom in the preview(if you are using simulator, try to press the Option Key on the keyboard and drag the mouse). The preview image you provided in the lower version is blank(under "1 Copy" line). If this preview has been loaded, you could do this operation.
Best Regards,
Wenyan Zhang
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.