I'm working on Xamarin.Forms based project, trying to print the webview content with pagination.
I've referred the following link already:
https://stackoverflow.com/questions/17049677/how-do-i-print-webview-content-in-a-windows-store-app
But unfortunately this way is not working with Xamarin.Forms because the way demonstrated in the above link is by filling the rectangle(windows shape) using webviewbrush. The problem is we can't use webviewbrush to draw rectangle(Xamarin Forms shape).
As a workaround I did the following:
- created a boxview in xamarin forms PCL project
- created a renderer for this boxview in UWP project(this will give us the windows rectangle shape) and then I did put this rectangle shape as an instance property in PCL project's App.cs class to make it available for Webviewrenderer.cs class for filling this rectangle with webviewbrush.
- I can able to access it from webviewrenderer.cs class from UWP project but the problem is the printer dialog shows an empty page.
Apparently the problem would be with rectangle. Because the same logic is just works fine if I create a native UWP project and the printer dialog shows the webpage as well.
Any help would be much appreciated.
Thanks in advance!
I've referred the following link already:
https://stackoverflow.com/questions/17049677/how-do-i-print-webview-content-in-a-windows-store-app
But unfortunately this way is not working with Xamarin.Forms because the way demonstrated in the above link is by filling the rectangle(windows shape) using webviewbrush. The problem is we can't use webviewbrush to draw rectangle(Xamarin Forms shape).
As a workaround I did the following:
- created a boxview in xamarin forms PCL project
- created a renderer for this boxview in UWP project(this will give us the windows rectangle shape) and then I did put this rectangle shape as an instance property in PCL project's App.cs class to make it available for Webviewrenderer.cs class for filling this rectangle with webviewbrush.
- I can able to access it from webviewrenderer.cs class from UWP project but the problem is the printer dialog shows an empty page.
Apparently the problem would be with rectangle. Because the same logic is just works fine if I create a native UWP project and the printer dialog shows the webpage as well.
Any help would be much appreciated.
Thanks in advance!