Getting started with XFINIUM.PDF Viewer in Android applications

This tutorial will show how to get started with XFINIUM.PDF Viewer in Xamarin.Android applications.

1. Create a new Android application.

Getting started with XFINIUM.PDF viewer in Android applications

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.

Getting started with XFINIUM.PDF viewer in Android applications

4 thoughts on “Getting started with XFINIUM.PDF Viewer in Android applications”

  1. When running this is very slowly, you can see it render the page, how to make it faster, compare to native adobe viewer.

    1. 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?

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: