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

ScaleFactor NOT working

2 Answers 218 Views
PDFViewer
This is a migrated thread and some comments may be shown as answers.
David Ellams
Top achievements
Rank 1
David Ellams asked on 23 Jul 2013, 05:29 PM
Greetings,


I have been evaluating your excellent RadPDFViewer control which I am pleased with.

But the ScaleFactor does not appear to be working? I set in code and nothing happens. I also set it in the DocumentChanged event as you suggest and still nothing?

I hope you can help us?

Any help would be greatly appreciated.

This is really urgent since I am a freelance contractor working on a short-term project and the client needs a very quick turn around, ideally before my contract ends very soon! :)

Many thanks,
David.
P.S. It also appears REALLY slow when used in a frame, has anyone else seen this?

2 Answers, 1 is accepted

Sort by
0
Wenjie
Top achievements
Rank 1
answered on 24 Jul 2013, 07:28 PM
try this.
<Window x:Class="WpfApplication99.MainWindow"
        Title="MainWindow" Height="350" Width="525">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="auto"/>
            <RowDefinition Height="auto"/>
            <RowDefinition/>
        </Grid.RowDefinitions>
        <StackPanel Orientation="Horizontal">
            <TextBlock Text="ScaleFactor"></TextBlock>
            <TextBox Width="50" Margin="30,0,0,0" Text="{Binding ElementName=c1PdfViewer1, Path=ScaleFactor,Mode=OneWay}"></TextBox>
            <TextBlock  Margin="30,0,0,0" Text="change ScaleFactor by hardcode" ></TextBlock>
            <Button Margin="30,0,0,0" Width="50" Click="Button_Click"></Button>
        </StackPanel>
        <ToolBarTray UseLayoutRounding="False" Background="sc#1.000000, 0.769689, 0.831936, 1.000000" Grid.Row="1" >
            <ToolBar DataContext="{Binding ElementName=c1PdfViewer1, Path=Commands}" >
                <Button Width="40" ToolBar.OverflowMode="AsNeeded" Content="Load" HorizontalAlignment="Left" VerticalAlignment="Stretch" Margin="2" Padding="0" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Click="btnLoadFile_Click" >
                    <ToolTipService.ToolTip>
                        <TextBlock Text="Open" />
                    </ToolTipService.ToolTip>
                    
                </Button>
                <telerik:RadButton Command="{Binding ZoomInCommand}" HorizontalAlignment="Left" VerticalAlignment="Stretch" Margin="2" Padding="0" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" IsBackgroundVisible="False">
                <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 x:Name="PART_btnZoomOut" Command="{Binding ZoomOutCommand}" HorizontalAlignment="Left" VerticalAlignment="Stretch" Margin="2" Padding="0" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" IsBackgroundVisible="False">
                <ToolTipService.ToolTip>
                    <TextBlock Text="Zoom out" />
                </ToolTipService.ToolTip>
                <Image Source="/Telerik.Windows.Controls.FixedDocumentViewers;component/Images/zoom-out.png" Stretch="None" />
                </telerik:RadButton>
            </ToolBar>
        </ToolBarTray>
        <telerik:RadPdfViewer Name="c1PdfViewer1" Grid.Row="2"  DocumentChanged="c1PdfViewer1_DocumentChanged" >
        </telerik:RadPdfViewer>
    </Grid>
</Window>

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
 
namespace WpfApplication99
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }
 
        private void btnLoadFile_Click(object sender, RoutedEventArgs e)
        {
            e.Handled = true;
 
            string strPdfFilenName = "";
            var dlg = new Microsoft.Win32.OpenFileDialog();
            dlg.Filter = "PDF files (*.pdf)|*.pdf";
 
            if (dlg.ShowDialog().Value)
            {
                strPdfFilenName = dlg.FileName;
 
                System.IO.FileStream fstreamLoaded = new System.IO.FileStream(strPdfFilenName, System.IO.FileMode.Open, System.IO.FileAccess.Read);
 
                System.IO.MemoryStream mstreamPdfShow = new System.IO.MemoryStream();
 
                fstreamLoaded.CopyTo(mstreamPdfShow);
 
                Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.PdfFormatProvider prvdPdfPrint = new Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.PdfFormatProvider(mstreamPdfShow, Telerik.Windows.Documents.Fixed.FormatProviders.FormatProviderSettings.ReadAllAtOnce);
 
                this.c1PdfViewer1.Document = prvdPdfPrint.Import();
 
            }
 
        }
 
        private void c1PdfViewer1_DocumentChanged(object sender, EventArgs e)
        {
 
            if (c1PdfViewer1.Document != null)
            {
                this.c1PdfViewer1.ScaleFactor = 2.0;
               
            }
        }
 
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            if (c1PdfViewer1.Document != null)
            {
                this.c1PdfViewer1.ScaleFactor = 1;
 
            }
        }
    }
}
0
Petya
Telerik team
answered on 26 Jul 2013, 12:11 PM
Hi David,

As far as we are aware the ScaleFactor property of RadPdfViewer works fine. It is indeed recommended to place it in the DocumentChanged event handler (as in the snippet pasted by Wanjie) when you want the same scale factor to be set for each document loaded in the viewer. In case you are having troubles with this, please share additional details on your setup.

Furthermore, we are unaware of any performance issues at this point, so we will highly appreciate if you open a support ticket and attach your project, so that we can troubleshoot it on our side.

We are looking forward to your reply.

Regards,
Petya
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Tags
PDFViewer
Asked by
David Ellams
Top achievements
Rank 1
Answers by
Wenjie
Top achievements
Rank 1
Petya
Telerik team
Share this question
or