Forum Xamarin.iOS


The Xamarin Forums have officially moved to the new Microsoft Q&A experience. Microsoft Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

To create new threads and ask questions head over to Microsoft Q&A for .NET and get involved today.

Code for saving UIView as PDF in Xamarin.iOS

ranju_ranju_ Member ✭✭

I am trying to use below code for saving UI View as PDF as in the link:

partial void BtnTest_TouchUpInside(UIButton sender)

        public static NSMutableData createPDFFromView(UIView view)

            NSMutableData pdfData = new NSMutableData();

                // Points the pdf converter to the mutable data object and to the UIView to be converted

                UIGraphics.BeginPDFContext(pdfData, view.Bounds, null);
                UIGraphics.BeginPDFPage(view.Bounds, null);

                var pdfContext = UIGraphics.GetCurrentContext();


            catch (Exception ex)

            return pdfData;

Is this the complete code or I need to additional code to consume NSMutabledata returned by createPDFFromView method here?


Best Answer


Sign In or Register to comment.