Skip to main content
All docs
V18.2

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

How to: Add a PDF Viewer via Code

This example describes how to add a PDF Viewer to your WPF application in code.

To do this, perform the following actions:

  • Run MS Visual Studio 2012, 2013, 2015 or 2017.
  • Create a new WPF Application project or open an existing one.
  • Open the Solution Explorer, right-click References and choose Add Reference… to add the PDF Viewer Library.

    AddReference

  • Then, locate the DevExpress.Data.v18.2, DevExpress.Pdf.v18.2.Core, DevExpress.Xpf.DocumentViewer.v18.2.Core, and DevExpress.Xpf.PdfViewer.v18.2 assemblies and activate their check boxes.

    AddReference

    Click OK to apply changes and close the window.

  • Write the following code (or something similar).

    using DevExpress.Xpf.PdfViewer;
    using System.Windows;
    
    namespace AddPDFViewer {
    
        public partial class MainWindow : Window {
            public MainWindow() {
                InitializeComponent();
    
                // Create a PDF viewer control and add it to the window. 
                PdfViewerControl viewer = new PdfViewerControl();
                this.Content = viewer;          
            }
        }
    }
    

The PdfViewerControl has now been added to your application.

 

Tip

A complete sample project is available in the DevExpress Code Examples database at http://www.devexpress.com/example=T262332.