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.
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.
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.