Edit this page

Getting Started

RadPdfViewer is a control that allows you to display PDF files natively in Silverlight. 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 Silverlight 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

Adding RadPdfViewer to a Page

You have to first declare the Telerik namespace.

[XAML] Example 1: Declare the Telerik namespace

telerik="http://schemas.telerik.com/2008/xaml/presentation"     

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

[XAML] Example 2: Create a PdfViewer

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

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.

[XAML] Example 3: Add a RadToolBar to RadPdfViewer

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

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.

[XAML] 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">
    <ToolTipService.ToolTip>
        <TextBlock Text="Open" />
    </ToolTipService.ToolTip>
    <Image Source="{telerik:IconResource IconRelativePath=open.png, IconSources={StaticResource IconPaths}}" Stretch="None" />
</telerik:RadButton>

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