This tutorial will show how to get started with XFINIUM.PDF Viewer in Xamarin.Android applications.
1. Create a new Android application.
2. Add references to xfinium.pdf.xamarin.android.dll, xfinium.pdf.render.xamarin.android.dll, xfinium.pdf.view.xamarin.android.dll, xfinium.graphics.xamarin.android.skia.dll and skiasharp.dll in your project. Alternatively, for SkiaSharp.dll, you can also add a reference to SkiaSharp nuget package version 1.58.1.0.
3. Open your activity’s axml file.
4. Inside the layout code add this part:
<xfinium.pdf.view.PdfCoreView android:layout_width="fill_parent" android:layout_height="fill_parent" android:id="@+id/pdfView" />
The ‘xfinium.pdf.view.PdfCoreView‘ tag is case sensitive.
5. Add a test PDF file to your project and set its build action to EmbeddedResource.
6. In your activity’s OnCreate method create a PdfVisualDocument object, set the pdfView.Document property with the PdfVisualDocument object and load a file in the document.
pdfView = FindViewById(Resource.Id.pdfView); pdfView.GraphicRendererFactory = new Xfinium.Graphics.Skia.SkiaRendererFactory(); pdfView.Document = new PdfVisualDocument(); Assembly asm = Assembly.GetExecutingAssembly(); Stream pdfStream = asm.GetManifestResourceStream("XFINIUMPDFViewerForAndroid.xfinium.pdf"); pdfView.Document.Load(pdfStream); pdfStream.Close();
7. Run the application.
When running this is very slowly, you can see it render the page, how to make it faster, compare to native adobe viewer.
We are working on the performance issues, next versions will bring improvements in this area.
Hi, I still have speed issues in rendering. Is there any way to speed up rendering
Do you use the Skia rendering engine or the default (built-in) engine? Can you send us the PDF file so we can take a look at it?