Home > OS >  How can I save my Xamarin Forms MainPage.xaml as PDF using a button?
How can I save my Xamarin Forms MainPage.xaml as PDF using a button?

Time:05-19

On the front screen of the mobile app I have entries that I filled with info, now I want to make a button that saves the page as PDF with all the info I entered inside the entries. Help?

CodePudding user response:

There is a Nuget package called PdfSharp.Xamarin.Forms that takes a view and turns it into a pdf. Library link: https://github.com/akgulebubekir/PDFSharp.Xamarin.Forms

You have to init it fro each platform seperately: PdfSharp.Xamarin.Forms.{Platform}.Platform.Init()

Generate pdf : var pdf = PDFManager.GeneratePDFFromView(yourView)

Save pdf: DependencyService.Get().Save(pdf, "pdfName.pdf")

CodePudding user response:

There is a library to save and open PDF files in xamarin that might come in handy to you:

https://github.com/officialdoniald/Xamarin.Forms.Save.Open.PDF

Gerald Verslius has a video on it as well which can be found here : https://www.youtube.com/watch?v=FqetV1Lh-9c&ab_channel=GeraldVersluis

Sample: https://github.com/officialdoniald/Xamarin.Forms.Save.Open.PDF/tree/master/Xamarin.Forms.Save.Open.PDF

  • Related