Cannot open document

4 posts, 1 answers
  1. Oliver
    Oliver avatar
    263 posts
    Member since:
    Feb 2011

    Posted 04 Jul 2012 Link to this post

    Hi,

    I'm using Telerik V2012.1.325.35 and when I'm trying to open a PDF docuement using the PDFViewer. Here is the call stack:

    System.NullReferenceException was unhandled
      Message="La référence d'objet n'est pas définie à une instance d'un objet."
      Source="Telerik.Windows.Controls.FixedDocumentViewers"
      StackTrace:
           à Telerik.Windows.Documents.Fixed.FixedDocumentStreamSource.<>c__DisplayClass8.<LoadDocument>b__6() dans c:\TB\105\WPF_Scrum\Release_WPF\Sources\Development\Documents\Fixed\FixedDocumentViewers\Fixed\FixedDocumentStreamSource.cs:ligne 118
           à System.Threading.ThreadHelper.ThreadStart_Context(Object state)
           à System.Threading.ExecutionContext.runTryCode(Object userData)
           à System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
           à System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
           à System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
           à System.Threading.ThreadHelper.ThreadStart()
      InnerException:

    Here is my XAML:

    <UserControl x:Class="com.christiegrp.Neuron.ClientApplication.PdfViewer"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:converters="clr-namespace:Telerik.Windows.Documents.Converters;assembly=Telerik.Windows.Controls.FixedDocumentViewers"
        xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
        xmlns:controls="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls">

        <UserControl.Resources>
            <ResourceDictionary>
                <ResourceDictionary.MergedDictionaries>
                    <ResourceDictionary Source="PdfViewer-Fr-Res.xaml"/>
                    <ResourceDictionary Source="pack://application:,,,/Resources;component/Neuron-CustomStyles.xaml"/>
                </ResourceDictionary.MergedDictionaries>
            </ResourceDictionary>
        </UserControl.Resources>
       
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="*" />
            </Grid.RowDefinitions>

            <!-- The following element is used to trigger an event allowing to replace the language resources before they are used. -->
            <TextBlock Initialized="ReplaceLanguageResources"/>
           
            <telerik:RadToolBar x:Name="pdfToolBar" DataContext="{Binding ElementName=pdfViewer, Path=Commands}">
                <telerik:RadToolBar.Resources>
                    <converters:DoubleToStringPercentConverter x:Key="doubleToStringPercentConverter" />               
                </telerik:RadToolBar.Resources>

                <controls:RadButton Padding="4" Command="{Binding OpenPdfDocumentCommand}">
                    <ToolTipService.ToolTip>
                        <TextBlock Text="{StaticResource Open}" />
                    </ToolTipService.ToolTip>
                    <Image Source="/Telerik.Windows.Controls.FixedDocumentViewers;component/Images/open.png" Stretch="None" />
                </controls:RadButton>

                <controls:RadButton Command="{Binding PrintPdfDocumentCommand}">
                    <ToolTipService.ToolTip>
                        <TextBlock Text="{StaticResource Print}" />
                    </ToolTipService.ToolTip>
                    <Image Source="/Telerik.Windows.Controls.FixedDocumentViewers;component/Images/printer.png" Stretch="None" />
                </controls:RadButton>

                <telerik:RadToolBarSeparator/>

                <controls:RadButton Command="{Binding PageUpCommand}" >
                    <ToolTipService.ToolTip>
                        <TextBlock Text="{StaticResource PreviousPage}" />
                    </ToolTipService.ToolTip>
                    <Image Source="/Telerik.Windows.Controls.FixedDocumentViewers;component/Images/previous.png" Stretch="None" />
                </controls:RadButton>

                <controls:RadButton Command="{Binding PageDownCommand}">
                    <ToolTipService.ToolTip>
                        <TextBlock Text="{StaticResource NextPage}" />
                    </ToolTipService.ToolTip>
                    <Image Source="/Telerik.Windows.Controls.FixedDocumentViewers;component/Images/next.png" Stretch="None" />
                </controls:RadButton>

                <TextBox Width="30" Margin="2" Text="{Binding FixedDocumentViewer.CurrentPageNumber, Mode=TwoWay}" HorizontalContentAlignment="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/>

                <controls:RadButton Command="{Binding ZoomInCommand}">
                    <ToolTipService.ToolTip>
                        <TextBlock Text="{StaticResource ZoomIn}" />
                    </ToolTipService.ToolTip>
                    <Image Source="/Telerik.Windows.Controls.FixedDocumentViewers;component/Images/zoom-in.png" Stretch="None" />
                </controls:RadButton>

                <controls:RadButton x:Name="PART_btnZoomOut" Command="{Binding ZoomOutCommand}">
                    <ToolTipService.ToolTip>
                        <TextBlock Text="{StaticResource ZoomOut}" />
                    </ToolTipService.ToolTip>
                    <Image Source="/Telerik.Windows.Controls.FixedDocumentViewers;component/Images/zoom-out.png" Stretch="None" />
                </controls:RadButton>

                <telerik:RadComboBox IsEditable="True" Margin="2" Width="70" SelectedIndex="4"
                                     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 />

                <controls:RadToggleButton IsChecked="{Binding FixedDocumentViewer.IsInPanMode, Mode=TwoWay}" >
                    <ToolTipService.ToolTip>
                        <TextBlock Text="{StaticResource Pan}" />
                    </ToolTipService.ToolTip>
                    <Image Source="/Telerik.Windows.Controls.FixedDocumentViewers;component/Images/hand-free.png" Stretch="None" />
                </controls:RadToggleButton>
            </telerik:RadToolBar>
           
            <telerik:RadPdfViewer Grid.Row="1" x:Name="pdfViewer" />
        </Grid>
    </UserControl>


    Thank's
  2. Iva Toteva
    Admin
    Iva Toteva avatar
    1319 posts

    Posted 09 Jul 2012 Link to this post

    Hi Oliver,

    There are two possible causes of the incorrect behavior - there is either a bug in the import, which is specific to the files you have tried to load, or the root of the problem is specific to the way you have implemented your project.

    Could you provide some more details on the issue, namely:

    1. How are you opening the document, i.e. are you using the button in the toolbar? If not, please share with us the code that you are using to set the document in code-behind. In addition, make sure to have added all required assembly references listed here.

    2. Does the issue occur with all PDF files or with a few specific ones? Please, try opening the documents in our click-once demos and if they are not shown that would mean that there is a bug in the import. If that is the case, we would appreciate it if you could open a support ticket and attach some of the files that can be used to reproduce the problem.

    Looking forward to your reply.


    Regards,
    Iva Toteva
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  3. UI for WPF is Visual Studio 2017 Ready
  4. Oliver
    Oliver avatar
    263 posts
    Member since:
    Feb 2011

    Posted 09 Jul 2012 Link to this post

    Hi Iva,

    1.Yes I'm trying to open the document with the button in the toolbar.
    2. This occur with any pdf documents, if I use the click-one demos, it work.

    All  needed references are in my project.

    Thank's
  5. Answer
    Iva Toteva
    Admin
    Iva Toteva avatar
    1319 posts

    Posted 10 Jul 2012 Link to this post

    Hello Oliver,

    The fact that the files are successfully opened in the demos means that there is no bug in the import in the latest version. Unfortunately, I have no idea what could be the cause for the incorrect behavior in your application other than missing assembly references.

    Could you please open a support ticket and attach your application or a small demo illustrating the issue?

    Looking forward to your reply.


    Kind regards,
    Iva Toteva
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Back to Top