Telerik blogs
The first big bang for this year brought to you a great set of components for your enterprise applications – RadPivotGrid, RadPdfViewer, as well as improvements in RadChartView. Today, I would like to shed more light on RadPdfViewer and what it can do for your application and its end-users.

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. And let’s see what RadPdfViewer provides as a feature set.

Open PDF Documents

Of course, in order to view PDF documents, we should load them first. RadPdfViewer supports opening a PDF document from a file or from a stream. 
Here is how easy it is to open it from a file, you should only pass the file path:


Another option is to open it from a stream. This comes in handy when the PDF document is loaded from the web, from a server, or when the document is created within the application without being saved to the machine as a file. Here is a sample, where just for demo purposes we load a file into a stream and then pass the stream to RadPdfViewer:

using (FileStream fStream = File.OpenRead(@"C:\Cars.pdf"))
    MemoryStream mStream = new MemoryStream();
    fStream.Read(mStream.GetBuffer(), 0, (int)fStream.Length);

OnDemand Loading

Opening documents is important, but loading them in a time efficient manner is even more important. This is where the OnDemand loading comes. By default, when you open a PDF document, the whole document is read and rendered, which takes time. If the ReadingMode is set to OnDemand, RadPdfViewer renders only the page you will see after the document is loaded. The rest of the pages are rendered on demand, when the end-user navigates to them.

this.radPdfViewer1.ReadingMode = ReadingMode.OnDemand;


Of critical importance when working with lengthy documents comes the Search functionality. It will allow your end-users to easily find the word, hence the topic they are looking for. This is how you can engage the Search functionality in code -  let’s search for the word “domain model”:

// Caution: This API will be available as of Q1 2013 SP1        
// Find Next
SearchResult searchResult = this.radPdfViewer1.PdfViewerElement.Find("domain model");
if (searchResult.Result != null)
// Find Previous
SearchResult searchResult = this.radPdfViewer1.PdfViewerElement.FindPrevious("domain model");
if (searchResult.Result != null)

PDF Viewer for WinForms Text Search by Telerik


Today, we  usually work on the go and a desktop machine is not always an option. Sometimes we have to switch to laptops and tablets. In this case, and wherever we have pages full of content that can be hardly read even of desktop machines, we have implemented the zoom in/out feature. This is how you can zoom in/out a PDF document specifying the percentage by which the document should be zoomed in/out:

// For 40%
this.radPdfViewer1.ScaleFactor = 0.4f;

PDF Viewer for WinForms PDF Zoom by Telerik

Pan Scroll and Text Selection

A natural extension to the zoom feature, the pan scroll will allow you to drag the zoomed document so that you can see the part of it that you are interested in. In order to turn it on, you should set the ViewerMode to Pan (which is actually the default value):

this.radPdfViewer1.ViewerMode = FixedDocumentViewerMode.Pan;

PDF Viewer for WinForms PDF Pan by Telerik

Setting the ViewerMode to TextSelection will allow the end-user to mouse select text instead of panning:

this.radPdfViewer1.ViewerMode = FixedDocumentViewerMode.TextSelection;

PDF Viewer for WinForms PDF Text Selection by Telerik


Annotations in the form of links will allow you to easily navigate between sections within a single document, or navigate to external web links. In the first case, you might have a book with a Table of Content and thanks to the annotations you will be able to quickly jump to the selected chapter:

PDF Viewer for WinForms PDF Internal Annotations by Telerik

PDF Viewer for WinForms PDF Web Annotations by Telerik

Navigation by Page

RadPdfViewer supports scrolling a PDF document out-of-the-box. But what if the end-user prefers navigating in a document in a page-by-page manner, i.e. going to a page and then by a single click going to the text one, without dragging around the mouse or using the mouse wheel? The Navigation by Page functionality of RadPdfViewer will fit nicely in this case. This is how you can programmatically go to the previous/next page:

// Previous Page
// Next Page


RadPdfViewer supports the printing functionality you are used to, exposing the same set of features and dialogs that you have at hand when printing RadGridView and RadScheduler. Here is how easy it is to employ the printing functionality of RadPdfViewer with code:


PDF Viewer for WinForms PDF Web Annotations by Telerik

Build-in Navigator

In the paragraphs above we demonstrated what features RadPdfViewer has to offer and how to use them in code. I am sure that you would find it prettier if the features are made available to the end-users thanks to a built-in user interface. We thought the same, so we built a simple, but powerful UI called RadPdfViewerNavigator that will allow the end-users to:
  • Load a PDF document from file
  • Print a PDF document
  • Zoom In/Out (by percent)
  • Scroll Up/Down by a page
  • Search
  • Pan Scrolling\TextSelection switch

The end-user can also navigate, search, select and print from the built-in context menu:

Theming Support

In order for RadPdfViewer to fit natively in your application, it supports the same styling mechanism which applies to all RadControls. From the screenshots below you can see that the scrollbar and the context menu styling are changed depending on the selected theme. You can also see the change in the RadPdfViewerNavigator style as well:

PDF Viewer for WinForms PDF Web Annotations by Telerik
RadPdfViewer, RadPdfViewerNavigator and RadForm with TelerikMetroBlue theme

PDF Viewer for WinForms PDF Web Annotations by Telerik
RadPdfViewer, RadPdfViewerNavigator and RadForm with VisualStudio2012Dark theme

Happy coding!

Download RadControls for WinForms by Telerik

About the Author

Nikolay Diyanov

Diyanov is the Product Manager of the Native Mobile UI division at Progress. Delivering outstanding solutions that make developers' lives easier is his passion and the biggest reward in his work. In his spare time, Nikolay enjoys travelling around the world, hiking, sun-bathing and kite-surfing.

Find him on Twitter @n_diyanov or on LinkedIn.

Related Posts


Comments are disabled in preview mode.