We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

How to use Pdfium rendering engine with PdfViewer in Xamarin Forms Android

By default, PdfViewer uses native Android PDF rendering. But, it also provides options in both Xamarin.Forms Android and Xamarin.Android platforms to use Pdfium that is a third party open source PDF rendering engine. Pdfium is the solution for overcoming defects in native Android rendering.     

 

Creating Pdfium binding library

 

To use Pdfium in your application, the Pdfium binding library is needed. A Pdfium binding library has already been created for your convenience and  is available with the demo sample attached at the bottom of this article.

The Pdfium binding project can also be created from scratch by following the steps below.

 

  1. Download the pdfium-android-1.7.0.aar android archive file from  https://mvnrepository.com/artifact/com.github.barteksc/pdfium-android/1.7.0

 

  1. To create the binding project from this archive file, refer to https://developer.xamarin.com/guides/android/advanced_topics/binding-a-java-library/binding-an-aar/

 

  1. Install the Xamarin.Android.Support.Compat dependency package in the project.

 

  1. Compile the project to generate the Pdfium library.

 

Using the Pdfium binding library in the application project

 

Refer to the binding library in your android project.   

Add a new class named “CustomPdfRenderer” to the android application project. This class must implement the ICustomPdfRenderer and ICustomPdfRendererService interfaces defined in the Syncfusion.SfPdfViewer.XForms.Droid and Syncfusion.SfPdfViewer.XForms namespaces respectively.

 

The entire CustomPdfRenderer class is given as follows.

C#

 

The CustomPdfRenderer property should be assigned to the AlternatePdfRenderer property of the CustomPdfRenderer class.

C#

 

Sample link:

http://www.syncfusion.com/downloads/support/directtrac/general/ze/PdfiumDemo1932199193

Article ID: Published Date: Last Revised Date: Platform: Control:
8860 06/21/2018 06/21/2018 Xamarin.Forms PdfViewer
Did you find this information helpful?
Add Comment
You must log in to leave a comment

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.