Nutrient

Home

SDK

Software Development Kits

Low-Code

IT Document Solutions

Workflow

Workflow Automation Platform

DWS API

Document Web Services

T
Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.

Company

About

Team

Careers

Contact

Security

Partners

Legal

Resources

Blog

Events

Try for free

Contact Sales
Contact sales
Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.

products

Web

Web

Document Authoring

AI Assistant

Salesforce

Mobile

iOS

Android

visionOS

Flutter

React Native

MAUI

Server

Document Engine

Document Converter Services

.NET

Java

Node.js

AIDocument Processing

All products

solutions

USECASES

Viewing

Editing

OCR and Data Extraction

Signing

Forms

Scanning & Barcodes

Markup

Generation

Document Conversion

Redaction

Intelligent Doc. Processing

Collaboration

Authoring

Security

INdustries

Aviation

Construction

Education

Financial Services

Government

Healthcare

Legal

Life Sciences

All Solutions

Docs

Guides overview

Web

AIAssistant

Document Engine

iOS

Android

visionOS

Java

Node.js

.NET

Document Converter Services

Downloads

Demo

Support

Log in

Resources

Blog

Events

Pricing

Try for free

Free Trial

Company

About

Security

Partners

Legal

Contact Sales
Contact Sales
Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.

products

Products overview

Document Converter

Document Editor

Document Searchability

Document Automation Server

Integrations

SharePoint

Power Automate

Nintex

OneDrive

Teams

Window Servers

solutions

USECASES

Conversion

Editing

OCR Data Extraction

Tagging

Security Compliance

Workflow Automation

Solutions For

Overview

Legal

Public Sector

Finance

All Solutions

resources

Help center

Document Converter

Document Editor

Document Searchability

Document Automation Server

learn

Blog

Customer stories

Events

Support

Log in

Pricing

Try for free

Company

About

Security

Partners

Legal

Contact Sales
Contact Sales
Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.

Product

Product overview

Process Builder

Form Designer

Document Viewer

Office Templating

Customization

Reporting

solutions

Industries

Healthcare

Financial

Manufacturing

Pharma

Education

Construction

Nonprofit

Local Government

Food and Beverage

Departments

ITServices

Finance

Compliance

Human Resources

Sales

Marketing

Services

Overview

Capex-accelerator

Process Consulting

Workflow Prototype

All Solutions

resources

Help center

guides

Admin guides

End user guides

Workflow templates

Form templates

Training

learn

Blog

Customer stories

Events

Support

Pricing

Support

Company

About

Security

Partners

Legal

Try for Free
Contact Sales
Try for Free
Contact Sales
Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.

Services

Generation

Editing

Conversion

Watermarking

OCR

Table Extraction

Pricing

Docs

Log in

Try for Free
Try for Free

Free trial

Blog post

Open a PDF on the Universal Windows Platform

James Swift James Swift

Table of contents

  • Getting Started
  • Rendering a PDF
  • Conclusion
Illustration: Open a PDF on the Universal Windows Platform

Often times, app developers need to quickly display a PDF document within their application. In this blog post, I’m going to show you how to quickly and easily open a PDF and display it in a UWP app using the UWP PDF framework.

Getting Started

To start, create a Visual C# Windows Universal blank application in Visual Studio.

Screenshot of a New Project window in Visual Studio

You’ll need an Image control on the main page and a button to open a file dialog to choose the PDF you want to render.

Open MainPage.xaml and change the content of the <Grid> element to add the above controls in two rows:

<Grid>
    <Grid.RowDefinitions>
        <RowDefinition Height="*"></RowDefinition>
        <RowDefinition Height="50"></RowDefinition>
    </Grid.RowDefinitions>
    <Image Name="PdfImage" Grid.Row="0" Margin="10"></Image>
    <Button Grid.Row="1" Margin="10,0,0,0" >Open</Button>
</Grid>

Your XAML should look like the following in the designer.

Main Page XAML

Next, add a click event handler for the button to the XAML:

<Button Grid.Row="1" Margin="10,0,0,0" Click="Button_Click_Open_PDF">Open</Button>

The following method in the MainPage class handles the click, which will open a file picker dialog. Note that the method must be async:

private async void Button_Click_Open_PDF(object sender, RoutedEventArgs e)
{
    var picker = new FileOpenPicker
    {
        ViewMode = PickerViewMode.Thumbnail,
        SuggestedStartLocation = PickerLocationId.DocumentsLibrary
    };
    picker.FileTypeFilter.Add(".pdf");

    var file = await picker.PickSingleFileAsync();

    if (file == null) return;

    // Open and display the PDF.
}

Rendering a PDF

To render the PDF file first, you need to open it. Add the following property and method to the MainPage class:

private PdfDocument _myDocument { get; set; }

private async Task OpenPDFAsync(StorageFile file)
{
    if (file == null) throw new ArgumentNullException();

    _myDocument = await PdfDocument.LoadFromFileAsync(file);
}

Then add the call to OpenPDFAsync to Button_Click_Open_PDF:

// Open and display the PDF.
    await OpenPDFAsync(file);
}

Now add a method for rendering a page of an open document to the Image control:

private async Task DisplayPage(uint pageIndex)
{
    if (_myDocument == null)
    {
        throw new Exception("No document open.");
    }

    if (pageIndex >= _myDocument.PageCount)
    {
        throw new ArgumentOutOfRangeException($"Document has only {_myDocument.PageCount} pages.");
    }

    // Get the page you want to render.
    var page = _myDocument.GetPage(pageIndex);

    // Create an image to render into.
    var image = new BitmapImage();

    using (var stream = new InMemoryRandomAccessStream())
    {
        await page.RenderToStreamAsync(stream);
        await image.SetSourceAsync(stream);

        // Set the XAML `Image` control to display the rendered image.
        PdfImage.Source = image;
    }
}

Add a call to DisplayPage to Button_Click_Open_PDF:

// Open and display the PDF.
await OpenPDFAsync(file);
await DisplayPage(0);

Now build and run the app, and once it’s running, click on the Open button.

Open File

Choose a PDF, click Open, and you should see something like the following.

Display File

As you can see, adding buttons to change pages is straightforward. Zooming, printing, and rotating require more work, but they are all possible with the standard UWP framework.

Conclusion

With very little effort, you can start displaying PDFs in your app in minutes.

If you’re looking for a solution that includes a fully responsive and customizable user interface, support for editing various annotation types, interactive forms and signatures, mobile support, persistence management, and many more features, look no further.

We at PSPDFKit offer an enterprise-ready PDF solution for UWP and other platforms, along with industry-leading first-class support included with every plan. Visit our UWP PDF SDK page to learn more, or try it out for free.

Explore related topics

Windows UWP C# How To
Free trial Ready to get started?
Free trial

Related articles

Explore more
SDKPRODUCTSWindowsReleases

PSPDFKit 3 for Windows: Customize and Improve

SDKPRODUCTSWindowsReleases

PSPDFKit 2.12: Visual Studio 2022 support

SDKPRODUCTSWindowsReleasesComponents

PSPDFKit 2.11 for Windows: Electronic Signatures

Company
About
Security
Team
Careers
We're hiring
Partners
Legal
Products
SDK
Low-Code
Workflow
DWS API
resources
Blog
Events
Customer Stories
Tutorials
News
connect
Contact
LinkedIn
YouTube
Discord
X
Facebook
Popular
Java PDF Library
Tag Text
PDF SDK Viewer
Tag Text
React Native PDF SDK
Tag Text
PDF SDK
Tag Text
iOS PDF Viewer
Tag Text
PDF Viewer SDK/Library
Tag Text
PDF Generation
Tag Text
SDK
Web
Tag Text
Mobile/VR
Tag Text
Server
Tag Text
Use Cases
Tag Text
Industries
Tag Text
Resources
Blog
Tag Text
Events
Customer Stories
Tag Text
Tutorials
Tag Text
Features List
Tag Text
Compare
Tag Text
community
Free Trial
Tag Text
Documentation
Tag Text
Nutrient Portal
Tag Text
Contact Support
Tag Text
Company
About
Tag Text
Security
Tag Text
Careers
Tag Text
Legal
Tag Text
Pricing
Tag Text
Partners
Tag Text
connect
Contact
Tag Text
LinkedIn
Tag Text
YouTube
Tag Text
Discord
Tag Text
X
Tag Text
Facebook
Tag Text
low-code
Document Converter
Tag Text
Document Editor
Tag Text
Document Automation Server
Tag Text
Document Searchability
Tag Text
Use Cases
Tag Text
Industries
Tag Text
Resources
Blog
Tag Text
Events
Customer Stories
Tag Text
Support
Help Center
Tag Text
Contact Support
Tag Text
Log In
Tag Text
Company
About
Tag Text
Careers
Tag Text
Security
Tag Text
Legal
Tag Text
Pricing
Tag Text
Partners
Tag Text
connect
Contact
Tag Text
LinkedIn
Tag Text
YouTube
Tag Text
Discord
Tag Text
X
Tag Text
Facebook
Tag Text
Popular
Approvals matrix
Tag Text
BPMS
Tag Text
Budgeting process
Tag Text
CapEx approval
Tag Text
CapEx automation
Tag Text
Document approval
Tag Text
Task automation
Tag Text
workflow
Overview
Tag Text
Services
Tag Text
Industries
Tag Text
Departments
Tag Text
Resources
Blog
Tag Text
Events
Customer Stories
Tag Text
Support
Help Center
Tag Text
FAQ
Tag Text
Troubleshooting
Tag Text
Contact Support
Tag Text
Company
About
Tag Text
Careers
Tag Text
Security
Tag Text
Legal
Tag Text
Pricing
Tag Text
Partners
Tag Text
connect
Contact
Tag Text
LinkedIn
Tag Text
YouTube
Tag Text
Discord
Tag Text
X
Tag Text
Facebook
Tag Text
DWS api
PDF Generator
Tag Text
Editor
Tag Text
Converter API
Tag Text
Watermark
Tag Text
OCR
Tag Text
Table Extraction
Tag Text
Resources
Log in
Tag Text
Help Center
Tag Text
Support
Tag Text
Blog
Tag Text
Company
About
Tag Text
Careers
Tag Text
Security
Tag Text
Pricing
Tag Text
Legal
Privacy
Tag Text
Terms
Tag Text
connect
Contact
Tag Text
X
Tag Text
YouTube
Tag Text
Discord
Tag Text
LinkedIn
Tag Text
Facebook
Tag Text

Copyright 2025 Nutrient. All rights reserved.

Thank you for subscribing to our newsletter!

We’re thrilled to have you join our community. You’re now one step closer to receiving the latest updates, exclusive content, and special offers directly in your inbox.

This builtin is not currently supported: DOM

PSPDFKit is now Nutrient. We've consolidated our group of trusted companies into one unified brand: Nutrient. Learn more

This builtin is not currently supported: DOM

PSPDFKit is now Nutrient. We've consolidated our group of trusted companies into one unified brand: Nutrient. Learn more

This builtin is not currently supported: DOM

New Feature Release. Tap into revolutionary AI technology to instantly complete tasks, analyze text, and redact key information across your documents. Learn More or View Showcase

This builtin is not currently supported: DOM

Aquaforest and Muhimbi are now Nutrient. We've consolidated our group of trusted companies into one unified brand: Nutrient. Learn more

This builtin is not currently supported: DOM

Integrify is now Nutrient. We've consolidated our group of trusted companies into one unified brand: Nutrient. Learn more

This builtin is not currently supported: DOM

Join us on April 15th. Join industry leaders, product experts, and fellow professionals at our exclusive user conference. Register for conference