This article demonstrates a simple Xamrin.Forms app that runs on Android, iOS and UWP. The app downloads a PDF from a given URL and displays basic information about the PDF using the .NET Standard 1.5 build of PDFKit.NET 5.0.
Here is the end result (UWP):
This code sample is included in the evaluation download. Path: \samples\CS\Xamarin_DocumentInfo\DocumentInfo.sln.
It is assumed that you have Visual Studio 2017 installed with Workloads Universal Windows Platform development and Mobile development with .NET
Create a new project
Create a new project of type Cross Platform App (Xamarin) Visual C#:
Next, select Blank App, Xamarin.Forms and Shared Project:
You will now have a solution with three platform specific projects for Android, iOS and UWP and a shared project:
We will change the shared project DocumentInfo only. The three platform specific projects will be left unchanged.
The Clicked handler of the ‘Fetch PDF from the URL…’ is implemented by method OnFetchButtonClicked as follows (error handling omitted):
void OnFetchButtonClicked(object sender, EventArgs args)
Uri uri = new Uri(urlField.Text);
using (WebClient client = new WebClient())
using (var fileStream = new MemoryStream(client.DownloadData(uri)))
Document doc = new Document(fileStream);
For the full code sample, we refer to the evaluation download.
no data is available for encoding 1252
You may get the error: no data is available for encoding 1252. This issue is discussed on Stack Overflow.
To solve this problem, go to Project Properties of the iOS project, select iOS Build and check west: