Getting Started
This article will guide you through the steps needed to add a basic RadPdfViewer control in your application.
- Setting up the app
- Adding the required Telerik references
- Adding RadPdfViewer control
- Visualize a Pdf Document
1. Setting up the app
Start by setting up the app. See the following articles for detailed instructions:
2. Adding the required Telerik references
To add the required Telerik references to your project, choose one of the three options:
- Add the entire Telerik.UI.for.Xamarin NuGet package.
-
Add only the Telerik.UI.for.Xamarin.PdfViewer NuGet package.
The NuGet package manager will automatically add the following dependencies: Telerik.UI.for.Xamarin.Common, Telerik.UI.for.Xamarin.Primitives, Telerik.UI.for.Xamarin.SkiaSharp, SkiaSharp and SkiaSharp.Views.Forms.
-
Add the references to all required Telerik assemblies manually.
The following table presents the required assemblies for the RadPdfViewer component:
Platform Assemblies Portable Telerik.Documents.Core.dll
Telerik.Documents.Fixed.dll
Telerik.XamarinForms.PdfViewer.dll
Telerik.XamarinForms.Common.dll
Telerik.XamarinForms.Primitives.dll
Telerik.XamarinForms.SkiaSharp.dllAndroid Telerik.Documents.Core.dll
Telerik.Documents.Fixed.dll
Telerik.Xamarin.Android.Primitives.dll
Telerik.Xamarin.Android.Common.dll
Telerik.XamarinForms.PdfViewer.dll
Telerik.XamarinForms.Common.dll
Telerik.XamarinForms.Primitives.dll
Telerik.XamarinForms.SkiaSharp.dlliOS Telerik.Documents.Core.dll
Telerik.Documents.Fixed.dll
Telerik.Xamarin.iOS.dll
Telerik.XamarinForms.PdfViewer.dll
Telerik.XamarinForms.Common.dll
Telerik.XamarinForms.Primitives.dll
Telerik.XamarinForms.SkiaSharp.dllUWP Telerik.Core.dll
Telerik.Documents.Core.dll
Telerik.Documents.Fixed.dll
Telerik.UI.Xaml.Primitives.UWP.dll
Telerik.XamarinForms.PdfViewer.dll
Telerik.XamarinForms.Common.dll
Telerik.XamarinForms.Primitives
Telerik.XamarinForms.SkiaSharp.dll
Add a reference to the Telerik.Documents.Core.dll and Telerik.Documents.Fixed.dll assemblies to each project. The assemblies are located in the
\Binaries\Portable
folder of your Telerik UI for Xamarin installation.
3. Adding RadPdfViewer control
Use one of the following approaches:
Drag the control from the Toolbox.
Take a look at the following topics on how to use the toolbox:
Create the control definition in XAML.
<telerikPdfViewer:RadPdfViewer x:Name="pdfViewer" />
After you create the control definition, add the following namespace:
xmlns:telerikPdfViewer="clr-namespace:Telerik.XamarinForms.PdfViewer;assembly=Telerik.XamarinForms.PdfViewer"
4. Visualize a Pdf Document
To visualize the pdf document, set the Source property of the control:
Func<CancellationToken, Task<Stream>> streamFunc = ct => Task.Run(() =>
{
Assembly assembly = typeof(PdfViewerGettingStartedXaml).Assembly;
string fileName = assembly.GetManifestResourceNames().FirstOrDefault(n => n.Contains("pdfviewer-overview.pdf"));
Stream stream = assembly.GetManifestResourceStream(fileName);
return stream;
});
this.pdfViewer.Source = streamFunc;
This is the result:
The example below shows a pdf document visualized as an EmbeddedResource. This is one of the options for loading a pdf with the PdfViewer control. For all available options, see the Key Features topic.