Updated 4/7/2014 to reflect Windows 8.1 PDF API capabilities and new SDK samples

Microsoft released a componentized, high-performing PDF viewing component for XAML/C# applications on 4/2/2014. Woohoo! This serves as a good reference sample of how this needs to be done (C# front-end with a C++ back-end).

If you want more bells and whistles, a number of third parties add more to the reader experience such as alternate viewing methods (facing page vs. continuous view, etc). Figure 1 shows a breakdown of all the components that I have seen. These are all expensive (from $495 to “if you have to ask, it’s too expensive”), so they might not work well for a hobbyist app developer. But if you have a need in your commercial or LOB application, you may find one of these to be useful. 

Vendor / Sample App Rendering Annotations Full Text Search License
PDFTron Mobile PDF SDK / Drawboard Proprietary Yes Yes $$$$
Foxit Embedded PDF SDK for Windows RT / Foxit Mobile PDF Proprietary Yes Yes $$$$
PDF Xpansion SDK / Perfect PDF Proprietary Yes Yes $$$$
DevExpress Windows 8 XAML Controls / Army Field Manuals Microsoft No No $$
ComponentOne XAML Controls / ComponentOne XAML Controls Microsoft* No No $$
Syncfusion Essential Studio for WinRT/XAML Proprietary No No $$
Windows.Data.PDF Microsoft No No MS-LPL
PdfShowcase Example Microsoft No No MS-LPL
MuPDF WinRT / PDF Touch Proprietary Yes No? GPL / $$$$
Offline Rasterization w/Ghostscript Proprietary No No GPL / $$$$
Any .NET Brokered Component** Proprietary Not Sure Not Sure Varied

Fig 1. PDF Viewing Components for Windows Store applications

* Offers two rendering modes – one that converts to XAML and another that uses the PDF API
** Windows 8.1 Update offers the ability for enterprise apps to broker desktop components for use in WinRT applications.

If you know of others, please post a reply or send me a tweet @paulwhit. I’m actively monitoring this topic.

Also Ahmed-Faoud has ported MuPDF for use in Windows Store applications. This is very fast, but carries a GPL license.

If high performance viewing of large or complex documents isn’t a consideration for your use case, you could provide rasterization to bitmap images either within your application at runtime or on a load event or background task, or by using a batch process like below. You could then load them in a ListView control and you should get pretty good performance. Rasterizing the PDF pages on the fly in a ListView is probably going to be too slow, especially on a low-powered device.

As an example, I’m using some C# code in a batch application to generate thumbnails for my Army Field Manuals app. I’m distributing the images with my app, so there’s no processor use on the client.

To rasterize the first page of a PDF document as a thumbnail, in a Windows Store application, add this to a button click event handler. The “file” variable is a file path. A quick way to access a local file is to put it in your %localappdata%\packages\{app id}\LocalState path and use ApplicationData.Current.LocalFolder to retrieve its file name.

var pdfDoc = await PdfDocument.LoadFromFileAsync(file);
var pdfPage = pdfDoc.GetPage(0);

var pageImageFile = await ApplicationData.Current.LocalFolder.CreateFileAsync(
"sm_" + Path.GetFileNameWithoutExtension(file.Path) + ".scale-100.png", CreationCollisionOption.ReplaceExisting);
var randomStream = await pageImageFile.OpenAsync(FileAccessMode.ReadWrite);
PdfPageRenderOptions options = new PdfPageRenderOptions();
options.DestinationWidth = 250;
await pdfPage.RenderToStreamAsync(randomStream, options);
await randomStream.FlushAsync();

randomStream.Dispose();
pdfPage.Dispose();

There is a team dedicated to the PDF APIs at Microsoft. You can find the PDF API team’s blog led by program manager Shalu Gupta on TechNet.

For the record, I am currently using DevExpress in my Army Field Manuals app.