This tutorial will show how to get started with XFINIUM.PDF Viewer in Xamarin.Mac applications.
1. Create a new Mac application using Visual Studio for Mac.
2. Add references to xfinium.pdf.xamarin.mac.dll, xfinium.pdf.render.xamarin.mac.dll, xfinium.pdf.view.xamarin.mac.dll, xfinium.graphics.xamarin.mac.coregraphics.dll in your project.
3. Open the application storyboard with Xcode/Interface Builder and add a custom view to it.
4. Set the custom view’s Class to PdfCoreView and embed it in a scroll view.
5. Create an outlet for the custom view and set its name to ‘documentView‘ (ignore the error about unknown type ‘PdfCoreView‘ in Xcode).
6. Save all the changes, close Xcode and return to Visual Studio for Mac.
7. Add a test PDF file to application’s Resources folder.
8. In view controller’s ViewDidLoad method create a PdfVisualDocument object, set the documentView.Document property with the PdfVisualDocument object and load a file in the document.
documentView.GraphicRendererFactory = new Xfinium.Graphics.CoreGraphics.CoreGraphicsRendererFactory(); documentView.Document = new Xfinium.Pdf.View.PdfVisualDocument(); FileStream pdfStream = File.OpenRead("xfinium.pdf"); documentView.Document.Load(pdfStream); pdfStream.Close();
9. Run the application.