Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Printing from a Xamarin.Forms app

I'm all new to Xamarin and I'm currently working on a sample or a "prove of concept" app using Xamarin.Forms.

I'm supposed to perform a print task from this app though I'm not at this point sure what to print yet (the screen, content of a label, a file etc.).

Either way, what is the easiest way to print from a Xamarin.Forms app? (current target is primarily Android 4.4+).

I hope this isn't too complicated :)

EDIT:

Ok let me just update this post as the original text might be a bit ambitious/vague.

I have a Xamarin.Forms project (+ an Android part) and I have some HTML available in the XF part of the project that I need to get into a WebView and print it. From what I understand, the thing with the WebView has to be done on the Android part of the project due to the fact that this is where the printing will be handled. I was hoping this could be done from code since I don't really need to display the WebView, just print it's content. The Android part of the project has only the MainActivity and no layouts or XAML files. I don't know where to add the WebView or how to access it (other than DependecyService seems to be a buzz word here) so I'm kinda stuck here.

I'm thinking that this task should be rather trivial to someone with a little more Xamarin experience than me.

like image 860
Aidal Avatar asked Mar 01 '16 10:03

Aidal


1 Answers

Every platform XF supports has it's own mechanism for printing. XF does not provide any abstractions for printing in a cross-platform manner. You will need to write printing logic for each layer and expose it to XF using DependencyService (or some other DI engine).

like image 158
Jason Avatar answered Sep 29 '22 09:09

Jason