How to print a PDF from the ViewModel instead of code behind

Hi I am trying to print a PDF from the ViewModel instead of the code behind and have been following the same method as used to save a PDF from the ViewModel, found here: https://www.syncfusion.com/forums/155480/trying-to-save-the-document-in-an-sfpdfviewer-from-viewmodel-instead-of-code-behind


I have created the IPrint interface and an EventToCommand behaviour but when creating an "OnDocumentPrint" command and using "DependencyService.Get<IPrintService>().Print(stream, fileName)" I'm not sure how to obtain the PDF stream.

Thanks for your help.


1 Reply

VD Vikram Devaraj Syncfusion Team September 30, 2021 03:44 PM UTC

Hi Thomas,

We have analyzed this requirement and we have KB article this will give idea about “How to obtain pdf stream to used for print”. Please refer below KB link to know more details .

https://www.syncfusion.com/kb/8767/how-to-print-pdf-documents-in-xamarin-forms-platform
 
Hope it helps you.If the provided information is not satisfied your requirement please update with more details.

Regards,
Vikram
 


Loader.
Up arrow icon