Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 75885

Printing on iPad from WebView

$
0
0

Hello guys,

I want to print a webview with the default printer functionalities which are available on both Android and iOS. I have a DependencyService with a Print method, which calls the platform specific code to access the printing functionalities. The problem is that it is not working on iPad, but it works on Android and iPhones.

The code for iOS is the following:

UIWebView platformWebView = (UIWebView)webView.PlatformControl;

UIPrintInteractionController printer = UIPrintInteractionController.SharedPrintController;

printer.ShowsPageRange = true;

printer.PrintInfo = UIPrintInfo.PrintInfo;
printer.PrintInfo.OutputType = UIPrintInfoOutputType.General;
printer.PrintInfo.JobName = name;

printer.PrintPageRenderer = new UIPrintPageRenderer()
{
    HeaderHeight = 40,
    FooterHeight = 40
};
printer.PrintPageRenderer.AddPrintFormatter(platformWebView.ViewPrintFormatter, 0);

printer.Present(true, (handler, completed, err) =>
{
});

I now that the printer.Present function is primary made for iPhones (http://iosapi.xamarin.com/?link=M:UIKit.UIPrintInteractionController.Present) but it should work when you use True als the first parameter (that's also conform the documentation, not in the doc at the link, but visible when you press F12 on the method in Visual Studio). The problem is that nothing is happening on the iPad when I call this method. No error, nothing.
I am aware of the method printer.PresentFromRectInView, but I don't know what I need to pass as the first two parameters (http://iosapi.xamarin.com/index.aspx?link=M:UIKit.UIPrintInteractionController.PresentFromRectInView).

Does anyone have a working printing solution for iPad?

Thanks in advance.

Regards,
Gerco


Viewing all articles
Browse latest Browse all 75885

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>