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. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to use Pdfium rendering engine with PdfViewer in Xamarin Android

By default, PdfViewer uses native Android PDF rendering to render the pages of the PDF document. It also provides options in both Xamarin.Forms Android and Xamarin.Android platforms to use Pdfium as an alternate, which is a third party open source PDF rendering engine. Using Pdfium rendering engine is the solution to overcome the defects in native Android PDF 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 and it is available with the demo sample attached at the bottom of this article for your convenience.

 

The Pdfium binding project can also be created from the scratch using 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 tohttps://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 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 interface defined in the Syncfusion.SfPdfViewer.Android namespace.

 

The entire CustomPdfRenderer class is given as follows.

C#

 

Create an instance of the CustomPdfRenderer class and assign it to the CustomPdfRenderer property of the PdfViewer.

 

C#

 

Sample link:

http://www.syncfusion.com/downloads/support/directtrac/general/ze/PdfiumDemo-920917237 

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

Warning Icon 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.Close Icon