We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to create PDF Viewer control in C# WPF?

Platform: WPF |
Control: PdfViewer |
Published Date: October 17, 2019 |
Last Revised Date: November 7, 2019

The WPF PDF viewer control supports viewing, reviewing, and printing PDF files in WPF applications. The thumbnail, bookmark, hyperlink, and table of contents support provides easy navigation within and outside the PDF files. The form-filling support provides a platform to fill, flatten, save, and print PDF files with AcroForm. The PDF files can be reviewed with the abundant available annotation tools.

Steps to create a PDF Viewer control in C# WPF application

Step 1: Create a new C# WPF application project.

Step 2: Install the Syncfusion.PdfViewer.WPF  NuGet package as a reference to your .NET Framework application.

Install the Syncfusion.PdfViewer.WPF NuGet package as a reference to your .NET framework application.

Step 3: Add the following Syncfusion namespace in MainWindow.xaml to make use of the PdfViewerControl.

XAML

<Window x:Class="MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:CreatePdfViewerControl"
        mc:Ignorable="d"
        xmlns:Syncfusion="clr-namespace:Syncfusion.Windows.PdfViewer;assembly=Syncfusion.PdfViewer.WPF" 
        Title="MainWindow" Height="450" Width="800" Loaded="Window_Loaded">

Step 4: Use the following code to initialize the PdfViewerControl from XAML.

XAML

<syncfusion:PdfViewerControl x:Name="PdfViewerControl"/>

Step 5: Use the Load API to view the PDF document using PdfViewerControl in MainWindow.xaml.cs file.

C#

private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            //Loads the document in PdfViewerControl
            PdfViewerControl.Load(@"..\..\Data\Barcode.pdf");
        }

Please find the sample from this GitHub location. Execution of PdfViewer Control sample will look alike as follows.

A screenshot of PDF viewer control.

UI customization

You can design and use your own UI for interacting with PDF files using the PdfDocumentView control. This control is exclusive for customization purpose and it supports only viewing the PDF files without having any other built-in UIs. We exposed equivalent APIs for all the functionalities, and you can bind it to your custom UI to make use of all the features. Refer to our API reference for more details.

Toolbar customization

You can design and use your own toolbar by hiding the built-in toolbar from the PdfViewerControl. Refer to this documentation for more details about toggling the visibility of the toolbar and also check out our custom toolbar example in GitHub location, where we have used ribbon control instead of built-in toolbar for PdfViewerControl. Execution of custom toolbar sample will look alike as follows.

A screenshot of a custom toolbar

Appearance customization

As it inherits from System.Windows.Controls.Control, you can change the appearance of the control to fit the look and feel of your application. You can customize the appearance either by creating your own control template or by choosing any of the Syncfusion supported built-in themes that are available in the Syncfusion.Shared.WPF assembly. Check out our visual styles example for the built-in themes supported by PdfViewer control in GitHub location. Execution of visual styles sample with theme “Office 2010 Blue” will look alike as follows.

A screenshot of visual styles sample.

Summary

For more information, refer to our user guide documentation. You can also refer to the Feature Tour site to get an overview on all the features in PDF Viewer. Refer this documentation  to know about the required assemblies for creating PDF Viewer control.

2X faster development

The ultimate WPF UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile