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

Getting Started with WinForms PdfViewer

Getting Started with the WinForms RadPdfViewer
RadPdfViewer enables you to easily load and display PDF documents natively in your app without using any third-party tools except Telerik’s WinForms toolbox. Thanks to its built-in UI virtualization, RadPdfViewer delivers a performant solution in every scenario. This component will come as a nice addition to your Content Management Systems and Reporting applications, let’s see what RadPdfViewer provides as a feature set.
WinForms RadPdfViewer Tutorial

This article will help you quickly get started with RadPdfViewer. To start off, drag and drop RadPdfViewer the control from the toolbox to your form.

As of R1 2021 RadPdfViewer is optimized to work together with RadPdfProcessing library model. The idea is to unify the underlying architecture of RadPdfViewer and PdfProcessing to allow feature parity. RadPdfViewer uses the new model by default. However, the user can easily switch to the old model by using the UsePdfProcessingModel and UsePdfProcessingModelDefaultValue boolean properties. They should be set before loading a PDF document.

  • UsePdfProcessingModel property: Gets or sets a value indicating weather the RadPdfViewer should use the new RadPdfProcessing rendering model on document import. The default value is true. If this property is set to false the RadPdfViewer will fall-back internally to use the old model.
  • UsePdfProcessingModelDefaultValue property: Gets or sets a default value for UsePdfProcessingModel property. The default value is true. When RadPdfViewer.UseOldRenderingDefaultValue is set all RadPdfViewer instances will use the specified model.

Once you have RadPdfViewer, you can set the ViewerMode option to a desired value.

Figure 1: Visual Studio Designer

WinForms RadPdfViewer Visual Studio Designer

There is also a property for the above setting which you can set in your code:

ViewerMode Property

this.radPdfViewer1.ViewerMode = FixedDocumentViewerMode.TextSelection;

Me.RadPdfViewer1.ViewerMode = FixedDocumentViewerMode.TextSelection

Loading a PDF document is done via the LoadDocument method. It accepts either a filename or an input stream as an argument.

LoadDocument Method

this.radPdfViewer1.LoadDocument(Application.StartupPath + "\\PdfViewer\\Sample.pdf");

Me.RadPdfViewer1.LoadDocument(Application.StartupPath & "\PdfViewer\Sample.pdf")

The calls above will start to load the specified document asynchronously. When the loading finishes, the DocumentLoaded event will fire:

DocumentLoaded Event

void radPdfViewer1_DocumentLoaded(object sender, EventArgs e)
    RadMessageBox.Show("The document was loaded.");

Private Sub radPdfViewer1_DocumentLoaded(sender As Object, e As EventArgs)
    RadMessageBox.Show("The document was loaded.")
End Sub

Respectively, to unload a document, you can use the UnloadDocument method

UnloadDocument Method



To provide to the end-user an additional set of abilities for manipulating the document, you can use RadPdfViewerNavigator. To do this, drag it from the toolbox to your form and set its AssociatedViewer from its SmartTag menu.

Figure 2. RadPdfViewerNavigator

WinForms RadPdfViewer RadPdfViewerNavigator

You can also set this in your code by using the AssociatedPdfViewer property of the PdfViewerNavigator.

this.radPdfViewerNavigator1.AssociatedViewer = this.radPdfViewer1;

Me.RadPdfViewerNavigator1.AssociatedViewer = Me.RadPdfViewer1

Assembly References

If you add the RadPdfViewer at run time you need to add references to the following assemblies:

  • Telerik.WinControls.PdfViewer

  • Telerik.WinControls

  • Telerik.WinControls.UI

  • TelerikCommon

  • Telerik.Windows.Documents.Fixed

  • Telerik.Windows.Documents.Core

  • Telerik.Windows.Zip.dll

See Also

In this article