New to Telerik UI for WPF? Download free 30-day trial

Getting Started

RadPdfViewer is a control that allows you to display PDF files natively in WPF. This topic helps you to quickly get started using the control. It focuses on the following:

Assembly References

The minimal set of assembly references you need to add to your WPF project in order to use RadPdfViewer are listed below:

  • Telerik.Windows.Controls.dll
  • Telerik.Windows.Controls.FixedDocumentViewers.dll
  • Telerik.Windows.Documents.Core.dll
  • Telerik.Windows.Documents.Fixed.dll
  • Telerik.Windows.Zip.dll

If you want to include a RadToolBar, you also need to reference:

  • Telerik.Windows.Controls.Input.dll
  • Telerik.Windows.Controls.Navigation.dll

You can also take advantage of some RadPdfViewer-specific controls such as FindDialog and PercentComboBox. To use them, you need to add the following references to your project:

  • Telerik.Windows.Controls.Input.dll
  • Telerik.Windows.Controls.Navigation.dll
  • Telerik.Windows.Controls.FixedDocumentViewersUI.dll

RadPdfViewer can also import and show documents containing predefined CMap tables. To enable this functionality with the default implementation, you will need to add a reference to:

  • Telerik.Windows.Documents.CMapUtils.dll

Check the CMap tables topic for more details on importing documents containing that feature.

Adding RadPdfViewer to a Page

You have to first declare the Telerik namespace.

Example 1: Declare the Telerik namespace

After that, you can add a RadPdfViewer, as shown in Example 2.

Example 2: Create a PdfViewer

    <telerik:RadPdfViewer x:Name="pdfViewer"/> 

When you create a RadPdfViewer, ensure that the control is not placed in a container that measures its children in Infinity as this could lead to unexpected behavior of the viewer. Examples of such containers are ScrollViewer, StackPanel or Grid with row height and column width set to Auto.

Wiring the UI with RadPdfViewer Commands

The navigation panel is separated from the control to provide better customization options. In order to add a panel in your application, you can use RadToolBar, which has the command descriptors of the viewer as a DataContext.

Since R1 2018, you can use the predefined UI of RadPdfViewer - RadPdfViewerToolBar. For more information, check the Default UI topic.

Example 3: Add a RadToolBar to RadPdfViewer

<telerik:RadToolBar DataContext="{Binding ElementName=pdfViewer, Path=CommandDescriptors}"> 

You can download a complete runnable example that shows the default RadPdfViewer with RadToolBar configuration from the Telerik® SDK repository.

You can then add buttons, combo boxes, etc., bound to the respective command descriptors of the viewer, as Example 4 shows.

Example 4: Wire a CommandDescriptor to a RadButton

<telerik:RadButton Command="{Binding OpenCommandDescriptor.Command}" Visibility="{Binding OpenCommandDescriptor.IsEnabled, Converter={StaticResource BoolToVisibilityConverter}}" HorizontalAlignment="Left" VerticalAlignment="Stretch" Margin="2" Padding="0" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" IsBackgroundVisible="False"> 
        <TextBlock Text="Open" /> 
    <Image Source="{telerik:IconResource IconRelativePath=open.png, IconSources={StaticResource IconPaths}}" Stretch="None" /> 

For the whole configuration of a RadToolBar with all commands of the viewer, you can refer to the Wiring UI article. More information about the command descriptors is available here.

After you configure RadPdfViewer in this way, the control is ready to use. Additional options, such as showing a PDF document when the viewer is loaded or binding the document, are described in the Showing a File article.

See Also

In this article
Not finding the help you need? Improve this article