How to Display PDF in Xamarin Forms With Ease – Pujolsluis Blog
Description: Recently, I was researching different ways of displaying PDFs within our Xamarin Forms Apps, and I found that it all boils down to the following approaches.
Date: 2020-08-12T11:50:48+00:00

# How to Display PDF in Xamarin Forms With Ease

in Xamarin on August 12, 2020 August 17, 2020 Share Facebook Twitter Pinterest Email
1 Like

Recently, I was researching different ways of displaying PDFs within our Xamarin Forms Apps, and I found that it all boils down to the following approaches.

The first thing we need to know is that it all depends on a few gotchas, like where is our PDF stored? Will it be locally stored on the device or remotely? Do we need to implement a viewer inside the app? Can we delegate the work to the Browser or any existing app?

## Let’s Get Started!

### File is stored remotely

Delegate work to Device Browser: If the PDF is stored remotely, we can simply pass the URL to the device browser and customize it. We can achieve this by leveraging Xamarin.Essentials library.

Code Snippet:

More info:
https://docs.microsoft.com/en-us/xamarin/essentials/open-browser?context=xamarin%2Fandroid&tabs=android

| Xamarin.Essentials Open Browser – Xamarin The Browser class in Xamarin.Essentials enable an application to open a web link in the optimized system preferred browser or the external browser.docs.microsoft.com

### File Stored in Device: delegating work to any existing app on the device

Delegate work to Device Launcher: This allows the user to select which App opens the PDF file such as Google Drive PDF Viewer. This can be achieved by leveraging Xamarin.Essentials library.

https://docs.microsoft.com/en-us/xamarin/essentials/launcher?context=xamarin%2Fandroid&tabs=android

| Xamarin.Essentials Launcher – Xamarin The Launcher class in Xamarin.Essentials enable an application to open a URI by the system.docs.microsoft.com

### File Stored in Device: embedded inside our app solutions

We can achieve this with the following two approaches:

Implement a Custom Viewer solution: We could implement a Custom Viewer to display the PDF directly in the app. We could also take advantage of a third party licensed component like Syncfusion, which offers you a bunch of features besides displaying just the PDF.

There is a great post made by one of our awesome community member Gerald Versluis

Custom Viewer:
https://blog.verslu.is/xamarin/xamarin-forms-xamarin/showing-pdf-files-xamarin-forms/

| Showing PDF files in Xamarin.Forms – Gerald Versluis This will be just a quick-and-dirty blog on showing PDF files in your Xamarin.Forms application. I got the question from an Italian friend who wanted to implement this into an app, so I thought I’d share it with the rest of you!blog.verslu.is

Note: UIWebView is now deprecated for iOS, and you must use WKWebView instead. -Virsanna

iOS Solution for Deprecated WebViewRenderer, use a WKWebViewRenderer by Vira Gryaznova – Virsanna

Syncfusion PDF Viewer:
https://www.syncfusion.com/xamarin-ui-controls/xamarin-pdf-viewer

| Xamarin PDF Viewer | View and review PDF files | Syncfusion Overview: The Xamarin PDF Viewer is a feature-rich and high-performance control to view and review PDF files in Xamarin.Forms applications. The bookmark, hyperlink, and table of contents support provide easy navigation within and outside PDF files. www.syncfusion.com

#### Ce Finito! 🎊☺️

Great Job! we are now able to display pdfs in any scenario we could encounter. I hope you have a great time trying out all of the solutions and implementing them in your future projects.

Made with ❤ by Pujolsluis

Special Thanks to Virsanna, Faiza Khan, Damian Castroviejo for their great contributions on this article. 🥳

(Visited 8,061 times, 1 visits today)
Android iOS Mobile Development Xamarin XamarinForms

### Share This

### Written By

#### Pujolsluis

I'm Luis Pujols a Software Engineer and Certified Xamarin Mobile Developer originally from the Dominican Republic. I currently work at CrossGeeks as part of an awesome team, developing in Xamarin Forms, In my free time, I'm a co-organizer of the DotNetDo software community, I also enjoy experimenting with new tech's, mentoring peers and attending or organizing software community events.

### You May Also Like

on November 11, 2019

## Debugging hiccups in Xamarin and how to overcome them

on July 18, 2020

## Mobile App Redesign for Developers: GitTrends

on January 26, 2021

## .NET Docs Show – Creating an OSS mobile app using Xamarin + Azure

### Leave A Comment Cancel reply

Your email address will not be published. Required fields are marked *

Comment *

Name *

Email *

Website

Δ

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

### Luis Pujols

I'm Luis Pujols a Software Engineer and Certified Xamarin Mobile Developer originally from the Dominican Republic. I currently work at CrossGeeks as part of an awesome team, developing in Xamarin Forms, In my free time, I'm a co-organizer of the DotNetDo software community, I also enjoy experimenting with new tech's, mentoring peers and attending or organizing software community events.
Search for:
https://www.youtube.com/watch?v=lRTsXA0mV9U

### Recent Posts

- [Workshop] Reactive Programming with .NET and Xamarin.Forms with Andres Pineda – .NET Dominicana
- [Study Group] Exam Prep Sessions For AZ-900 – .NET Dominicana
- [Panel] How to Become a Xamarin Developer – LATAM
- [Workshop] Azure For Devs – Week 5
- [Workshop] Azure For Devs – Week 4

### Recent Comments

- Pujolsluis on Google Client Plugin For Xamarin
- Surendra on Google Client Plugin For Xamarin
- Pujolsluis on Google Client Plugin For Xamarin
- Joe F on Google Client Plugin For Xamarin
- Pujolsluis on Google Plugin 1.1.0 Released: Goodies and Improvements