Telerik blogs

The long-awaited 2012 Q1 with the first official version of RadPdfViewer is already a fact! This is also the first release of the control for WPF, so don’t forget to check it out in the demos if you have missed it: WPF and Silverlight.

A big “Thank You” to all who tried using RadPdfViewer for Silverlight when it was still in a beta stage for providing such a valuable feedback on the control! We have come a long way with your help and hope that you will enjoy the improvements that the first official version brings out.


For the past few months after we first introduced RadPdfViewer as Beta, we have managed to extend the list of supported PDF features in order to be able to show correctly intrinsic PDF files like the ones normally used in LOB applications. The ameliorations include a wider set of image formats and an extensible architecture for plugging in custom filters. The text rendering system was also rethought and improved to ensure the professional look of the document preview. We also managed to implement clipping and support for color spaces, further polishing the way PDF files are shown. Last but not least, if you use the control in Silverlight 5, you will now be able to print your documents faster and with less memory footprint, because the control now utilizes the vector printing of Silverlight 5.

In the 2012 Q1 release an MVVM friendly API is introduced, which will help you integrate RadPdfViewer more easily. Following popular demand, the DocumentSource of RadPdfViewer has been implemented as a DependencyProperty, allowing data-binding to a Stream, a URI where a document can be found, or a string representing such a URI. For example, if Source is the property in your view-model which you wish to bind the content of the viewer to, you can do that as follows:

<telerik:RadPdfViewer x:Name="viewer" DocumentSource="{Binding Source, Converter={StaticResource PdfDocumentSourceValueConverter}}" />

PdfDocumentSourceValueConverter is a static resource declared as:

<fixed:PdfDocumentSourceValueConverter x:Key="PdfDocumentSourceValueConverter" />

The toolbar that RadPdfViewer used in the beta has been implemented as a separate control now in order to allow customizations of the functionality provided to the end user.

Here is an example of how a RadToolBar can be wired with the commands of the PdfViewer:

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

            …

  </telerik:RadToolBar>

After setting the DataContext of the toolbar, you can proceed to fill in buttons bound to the commands of the viewer like this:

            <controls:RadButton Padding="4" Command="{Binding OpenPdfDocumentCommand}">

                <ToolTipService.ToolTip>

                    <TextBlock Text="Open" />

                </ToolTipService.ToolTip>

                <Image Source="/Telerik.Windows.Controls.FixedDocumentViewers;component/Images/open.png" Stretch="None" />

            </controls:RadButton>

In this way, you will get the same button that the navigation panel of RadPdfViewer had in the beta version. Only that this time, you can customize the tooltip and the icon or even change the command executed. If you would like to preserve the look of the PdfViewer from the Beta, you can open the demos and copy the content from there. Of course, you can implement other kind of UI just as easily.

Now the experience you get with RadPdfViewer for Silverlight will be much closer to the desktop applications you use for viewing PDFs. What is more, you can build applications with similar look and functionality for Silverlight and WPF with minimal effort.

Happy developing! 


About the Author

Iva Toteva

is a software developer and works closely with clients to assist them in utilizing the RadControls they use for the purposes of their application. The controls in her domain include RadRichTextBox, RadSpreadsheet and RadPdfViewer.

Related Posts

Comments

Comments are disabled in preview mode.