Rendering PDF pages using pdfium in Xamarin Pdf Viewer (SfPdfViewer)
17 Mar 20231 minute to read
The Xamarin PDF Viewer allows using Pdfium, which is a third-party open-source PDF rendering engine, to render the pages of a PDF document. By default, the PdfViewer uses native PDF rendering. However, using the Pdfium rendering engine will overcome the defects in the native PDF rendering.
Setting the Renderer property
Set the CustomPdfRenderer
property to an instance of a class that implements the ICustomPdfRenderer
interface. Implementing this interface is explained in detail in the following sections.
If the CustomPdfRenderer
property is not set, the pages are rendered using the default rendering of the SfPdfViewer control.
The CustomPdfRenderer property should be assigned to the AlternatePdfRenderer property of the CustomPdfRenderer
class as in the following code sample,
// Provides functionality to render PDF pages using third-party PDF renderers.
pdfViewer.CustomPdfRenderer = DependencyService.Get<ICustomPdfRendererService>().AlternatePdfRenderer;
PDFium renderer sample
The sample that illustrates loading a PDF using the Pdfium renderer in Android and UWP can be downloaded from the link below.
https://www.syncfusion.com/downloads/support/directtrac/general/ze/PdfiumDemoSample-2002924505
NOTE
At present, this feature is available on Android and UWP platforms only.
NOTE
You can also explore our Xamarin.Forms PDF Viewer example to knows the functionalities of each feature.