This is a migrated thread and some comments may be shown as answers.

PDFViewer toolbar

2 Answers 498 Views
PDFViewer
This is a migrated thread and some comments may be shown as answers.
Kellie
Top achievements
Rank 1
Kellie asked on 17 Feb 2012, 06:47 PM
Question 1: How do I make the WPF PDFViewer toolbar show?

I currently have the following xaml:

<Grid  x:Name="LayoutRoot" DataContext="{StaticResource DataContext}">
    <telerik:RadPdfViewer x:Name="pdfViewer" DocumentSource="A10000292S_Notice.pdf" />
</Grid>

This xaml is in a System.Windows.Window.

Question 2: There is a "DocumentSource" property that I am successfully using, but what is the "Document" property for?

Thanks in advance.
Kellie Harrisson
Sierra Systems, Edmonton

2 Answers, 1 is accepted

Sort by
0
Kellie
Top achievements
Rank 1
answered on 22 Feb 2012, 05:30 PM
Even though this is a WPF PdfViewer, I ended up manually making a toolbar based on the Silverlight "FirstLook" demo.
I was hoping there was going to be one already built for the WPF PdfViewer where you could just set some properties to make it show.

Anyway, here's what I did:

<UserControl x:Class="CoE.VCS.WPF.Common.Controls.PDFViewerControl"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
             xmlns:TelerikConverters1="clr-namespace:Telerik.Windows.Documents.Fixed;assembly=Telerik.Windows.Controls.FixedDocumentViewers" 
             xmlns:TelerikConverters2="clr-namespace:Telerik.Windows.Documents.Converters;assembly=Telerik.Windows.Controls.FixedDocumentViewers" >
      
    <UserControl.Resources>
            <TelerikConverters1:PdfDocumentSourceValueConverter x:Key="PdfDocumentSourceValueConverter" />
    </UserControl.Resources>
          
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto" />
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
  
        <telerik:RadToolBar Grid.Row="0" DataContext="{Binding ElementName=pdfViewer, Path=Commands}">
  
            <telerik:RadToolBar.Resources>
                <TelerikConverters2:DoubleToStringPercentConverter x:Key="doubleToStringPercentConverter" />
            </telerik:RadToolBar.Resources>
            <telerik:RadButton Style="{x:Null}" Command="{Binding PageDownCommand}">
                <ToolTipService.ToolTip>
                    <TextBlock Text="Next Page" />
                </ToolTipService.ToolTip>
                <Image Source="/Telerik.Windows.Controls.FixedDocumentViewers;component/Images/next.png" Stretch="None"/>
            </telerik:RadButton>
            <telerik:RadButton Style="{x:Null}" Command="{Binding PageUpCommand}">
                <ToolTipService.ToolTip>
                    <TextBlock Text="Previous Page" />
                </ToolTipService.ToolTip>
                <Image Source="/Telerik.Windows.Controls.FixedDocumentViewers;component/Images/previous.png" Stretch="None"/>
            </telerik:RadButton>
  
            <TextBox Width="30" Margin="2" Text="{Binding FixedDocumentViewer.CurrentPageNumber, Mode=TwoWay}" 
                                             HorizontalContentAlignment="Center" VerticalContentAlignment="Center" x:Name="tbCurrentPage" 
                                             KeyDown="tbCurrentPage_KeyDown"/>
            <TextBlock VerticalAlignment="Center" Margin="2" Text="/" />
            <TextBlock VerticalAlignment="Center" Margin="2" Text="{Binding ElementName=pdfViewer, Path=Document.Pages.Count}" />
  
            <telerik:RadToolBarSeparator/>
  
            <telerik:RadButton Style="{x:Null}" Command="{Binding ZoomInCommand}">
                <ToolTipService.ToolTip>
                    <TextBlock Text="Zoom In" />
                </ToolTipService.ToolTip>
                <Image Source="/Telerik.Windows.Controls.FixedDocumentViewers;component/Images/zoom-in.png" Stretch="None"/>
            </telerik:RadButton>
            <telerik:RadButton Style="{x:Null}" Command="{Binding ZoomOutCommand}">
                <ToolTipService.ToolTip>
                    <TextBlock Text="Zoom Out" />
                </ToolTipService.ToolTip>
                <Image Source="/Telerik.Windows.Controls.FixedDocumentViewers;component/Images/zoom-out.png" Stretch="None"/>
            </telerik:RadButton>
  
            <telerik:RadComboBox Style="{x:Null}" IsEditable="True" Margin="2" Width="70" SelectedIndex="4" IsTextSearchEnabled="True" IsFilteringEnabled="True"
                                 Text="{Binding FixedDocumentViewer.ScaleFactor, Converter={StaticResource doubleToStringPercentConverter}, Mode=TwoWay}">
                <telerik:RadComboBoxItem Content="10%" />
                <telerik:RadComboBoxItem Content="25%" />
                <telerik:RadComboBoxItem Content="50%" />
                <telerik:RadComboBoxItem Content="75%" />
                <telerik:RadComboBoxItem Content="100%" />
                <telerik:RadComboBoxItem Content="150%" />
                <telerik:RadComboBoxItem Content="200%" />
                <telerik:RadComboBoxItem Content="500%" />
                <telerik:RadComboBoxItem Content="1000%" />
                <telerik:RadComboBoxItem Content="2000%" />
            </telerik:RadComboBox>
            <telerik:RadToolBarSeparator />
  
            <telerik:RadButton Style="{x:Null}" Command="{Binding PrintPdfDocumentCommand}">
                <ToolTipService.ToolTip>
                    <TextBlock Text="Print" />
                </ToolTipService.ToolTip>
                <Image Source="/Telerik.Windows.Controls.FixedDocumentViewers;component/Images/printer.png" />
            </telerik:RadButton>
  
            <telerik:RadToggleButton Style="{x:Null}" IsChecked="{Binding FixedDocumentViewer.IsInPanMode, Mode=TwoWay}" >
                <ToolTipService.ToolTip>
                    <TextBlock Text="Pan" />
                </ToolTipService.ToolTip>
                <Image Source="/Telerik.Windows.Controls.FixedDocumentViewers;component/Images/hand-free.png" Stretch="None" />
            </telerik:RadToggleButton>
  
        </telerik:RadToolBar>
  
        <telerik:RadPdfViewer Grid.Row="1" x:Name="pdfViewer" DocumentSource="20111028152401429_6.pdf" />
    </Grid>
</UserControl>


Kellie Harrisson
Sierra Systems, Edmonton, Canada
0
Kammen
Telerik team
answered on 27 Feb 2012, 05:43 PM

Hi Kellie,

1. This is the right way to create a toolbar for your application like the one in the demo. You can copy the toolbar from our WPF demo, which is the same. You can also refer to our online documentation, which includes the code of the default RadToolBar, used in the demos.

2. The Document property is exposed so you can see the pages count of the Document. It is also reserved for future use. You should use the DocumentSource property to set or bind the content of the document.

Regards,
Kammen
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
Lou
Top achievements
Rank 1
commented on 15 Mar 2022, 08:27 PM | edited

Never mind, I figured it out.  

I would delete this comment, but I can't find a way to do it.   lol

Tags
PDFViewer
Asked by
Kellie
Top achievements
Rank 1
Answers by
Kellie
Top achievements
Rank 1
Kammen
Telerik team
Share this question
or