Skip to main content

Getting Started

  • 2 minutes to read

This tutorial describes how to create a Windows 10 PDF Viewer that opens, previews, navigates and prints PDF documents.

  • Run Microsoft Visual Studio 2017.
  • Create a new Blank App (Universal Windows) project. If prompted, select the target and minimum platform versions that your application will support.

    PDF tutorial create app

  • Add a PdfViewerControl component to the project.

    To do this, drag the PdfViewerControl from the DX.19.2: Common Controls Toolbox tab and drop it onto the main page.

    The following code will be generated.

    <Page xmlns:my="using:DevExpress.UI.Xaml.Controls"
        x:Class="PDF_Viewer.MainPage"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:local="using:PDF_Viewer"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        mc:Ignorable="d">
    
        <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
            <my:PdfViewerControl />
        </Grid>
    </Page>
    

    You can add the PdfViewerControl by overwriting your MainPage.xaml file with this code without dragging the PdfViewerControl to the page. However, in this case, you need to manually add references to the following libraries.

    • DevExpress.Controls
    • DevExpress.Core

    To add them, right-click References in the Solution Explorer and select Add Reference… in the invoked context menu.

    Note

    To collect all assemblies that may be required for your application, use the Assembly Deployment Tool.

    The PDF Viewer is now in our application. Continue and specify the document to be loaded at the application start.

  • Copy a file (e.g., Demo.pdf) to a subdirectory of your project and include this file into your solution.

    PDF tutorial add file

  • Set the PdfViewerControl.ShowOpenDocumentButton property to true to enable end-users to choose a document to open using the Open dialog window. Specify a path to the file you wish to load by using the PdfViewerControl.DocumentUri property. The XAML below shows how to do this for Demo.pdf.

    <my:PdfViewerControl ShowOpenDocumentButton="True" DocumentUri="ms-appx:///Data/Demo.pdf"/>
    
  • Run the application.

    PDF tutorial final